fix(nextjs): Don't run webpack plugin on non-prod Vercel deployments#5603
Merged
lobsterkatie merged 6 commits intoAug 19, 2022
Conversation
Contributor
size-limit report 📦
|
Contributor
vladanpaunovic
left a comment
There was a problem hiding this comment.
Thanks @lobsterkatie!
Can we make sure that there is some test for this scenario?
Also, once we close this, we should try to understand how this can be solved in non-vercel environments.
39fc0be to
003a6ec
Compare
vladanpaunovic
approved these changes
Aug 19, 2022
Contributor
vladanpaunovic
left a comment
There was a problem hiding this comment.
Looking good now! Thanks @lobsterkatie!
70bdd0c to
6d723d9
Compare
6d723d9 to
ee43f3c
Compare
2 tasks
This was referenced Oct 26, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When someone adds our Vercel integration, it only adds sentry-cli-relevant environment variables to production deployments. This can cause non-production deployments to fail, because when the webpack loader tries to run, it doesn't find the information it needs. That said, there's a reason we only set the env variables for prod - we really shouldn't be creating releases or uploading sourcemaps for dev or preview deployments in any case.
This adds an environment check for vercel deployments (using the
VERCEL_ENVenv variable), and only enables the webpack plugin if the environment isproduction. To give users a way to override this, settingdisableClientWebpackPluginordisableServerWebpackPlugintofalsenow takes precedence over other checks, rather than being a no-op. Finally, given that the number of enablement checks is likely to grow, this pulls them into a separate function.This supersedes getsentry/sentry#37649.