diff --git a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js index fe223454746ea..13dc80f2fb7fb 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-browser.js @@ -28,8 +28,11 @@ const ShadowPortal = ({ children, identifier }) => { ) } -export const wrapRootElement = ({ element }) => { - if (process.env.GATSBY_PREVIEW_INDICATOR_ENABLED === `true`) { +export const wrapRootElement = ({ element }, pluginOptions) => { + if ( + process.env.GATSBY_PREVIEW_INDICATOR_ENABLED === `true` && + !pluginOptions?.disablePreviewUI + ) { return ( <> {element} diff --git a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js index c461d2392eec1..cd3b40a70871c 100644 --- a/packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js +++ b/packages/gatsby-plugin-gatsby-cloud/src/gatsby-node.js @@ -150,6 +150,9 @@ const pluginOptionsSchema = function ({ Joi }) { generateMatchPathRewrites: Joi.boolean().description( `When set to false, turns off automatic creation of redirect rules for client only paths` ), + disablePreviewUI: Joi.boolean().description( + `When set to true, turns off Gatsby Preview if enabled` + ), }) }