Skip to content

Commit 961f3d5

Browse files
authored
Wrap in env conditional (#27405)
1 parent 4ad9eb8 commit 961f3d5

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

packages/gatsby-plugin-sharp/src/gatsby-node.js

+17-15
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,21 @@ exports.onPreBootstrap = ({ actions, emitter, reporter }, pluginOptions) => {
6262
// normalizedOptions = setPluginOptions(pluginOptions)
6363
}
6464

65-
exports.pluginOptionsSchema = ({ Joi }) =>
66-
Joi.object({
67-
base64Width: Joi.number()
68-
.default(20)
69-
.description(`The width of the generated base64 preview image`),
70-
forceBase64Format: Joi.any()
71-
.valid(`png`, `jpg`, `webp`)
72-
.description(
73-
`Force a different format for the generated base64 image. Defaults to the same format as the input image`
65+
if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
66+
exports.pluginOptionsSchema = ({ Joi }) =>
67+
Joi.object({
68+
base64Width: Joi.number()
69+
.default(20)
70+
.description(`The width of the generated base64 preview image`),
71+
forceBase64Format: Joi.any()
72+
.valid(`png`, `jpg`, `webp`)
73+
.description(
74+
`Force a different format for the generated base64 image. Defaults to the same format as the input image`
75+
),
76+
useMozJpeg: Joi.boolean().description(
77+
`The the mozJpeg library for encoding. Defaults to false, unless \`process.env.GATSBY_JPEG_ENCODER\` === \`MOZJPEG\``
7478
),
75-
useMozJpeg: Joi.boolean().description(
76-
`The the mozJpeg library for encoding. Defaults to false, unless \`process.env.GATSBY_JPEG_ENCODER\` === \`MOZJPEG\``
77-
),
78-
stripMetadata: Joi.boolean().default(true),
79-
defaultQuality: Joi.number().default(50),
80-
})
79+
stripMetadata: Joi.boolean().default(true),
80+
defaultQuality: Joi.number().default(50),
81+
})
82+
}

0 commit comments

Comments
 (0)