Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-plugin-sharp): added option to allow sharp process to continue with errors #27345

Merged
merged 5 commits into from
Oct 12, 2020
Merged

feat(gatsby-plugin-sharp): added option to allow sharp process to continue with errors #27345

merged 5 commits into from
Oct 12, 2020

Conversation

joesanchezjr
Copy link
Contributor

Description

Added support for the passing of a plugin option that allows the sharp process to continue with errors so that sites with large media sites don't fail on gatsby develop or gatsby build.

This feature is optional and the default is set to fail on error (which is the current behavior)

Related Issues

Fixes #26857

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 8, 2020
Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Can we also have a note in README about the new option?

@vladar vladar added status: awaiting author response Additional information has been requested from the author topic: sharp and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Oct 9, 2020
@joesanchezjr
Copy link
Contributor Author

Yes! I'll work on adding that note today.

@joesanchezjr joesanchezjr requested a review from vladar October 12, 2020 16:24
@vladar
Copy link
Contributor

vladar commented Oct 12, 2020

This is so good, thank you 💜

There were some changes in plugin sharp in master recently - we've validation for the plugin options:

if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
exports.pluginOptionsSchema = ({ Joi }) =>
Joi.object({
base64Width: Joi.number()
.default(20)
.description(`The width of the generated base64 preview image`),
forceBase64Format: Joi.any()
.valid(`png`, `jpg`, `webp`)
.description(
`Force a different format for the generated base64 image. Defaults to the same format as the input image`
),
useMozJpeg: Joi.boolean().description(
`The the mozJpeg library for encoding. Defaults to false, unless \`process.env.GATSBY_JPEG_ENCODER\` === \`MOZJPEG\``
),
stripMetadata: Joi.boolean().default(true),
defaultQuality: Joi.number().default(50),
})
}

Can you merge master branch and add this option there as well? Sorry for the churn.

…or-option

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@joesanchezjr
Copy link
Contributor Author

@vladar No problem! I've merged master and added the new option to that object.

Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks 👍

@vladar vladar added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Oct 12, 2020
@gatsbybot gatsbybot merged commit 1da5926 into gatsbyjs:master Oct 12, 2020
@vladar
Copy link
Contributor

vladar commented Oct 12, 2020

Published in gatsby-plugin-sharp@2.6.42

Comment on lines +64 to +66
pipeline = !options.failOnError
? sharp(file, { failOnError: false })
: sharp(file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pipeline = sharp(file, { failOnError: options.failOnError })

why not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or

pipeline = sharp(file, { failOnError: !!options.failOnError })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes status: awaiting author response Additional information has been requested from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gatsby develop build fails when transforming images with sharp
4 participants