Skip to content

Commit 39fc0be

Browse files
committed
add vercel prod env check
1 parent 5172a7d commit 39fc0be

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ export function constructWebpackConfigFunction(
142142
// with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users
143143
// try to build their apps.)
144144
ensureCLIBinaryExists() &&
145+
// TODO: We might want to add detection for other non-prod environments
146+
!isVercelNonProdEnv() &&
145147
(isServer ? !userSentryOptions.disableServerWebpackPlugin : !userSentryOptions.disableClientWebpackPlugin);
146148

147149
if (enableWebpackPlugin) {
@@ -460,3 +462,9 @@ function ensureCLIBinaryExists(): boolean {
460462
}
461463
return false;
462464
}
465+
466+
/** Detect whether this build is part of a prod deployment on vercel, in order to decide whether to run the webpack
467+
* plugin */
468+
function isVercelNonProdEnv(): boolean {
469+
return process.env.VERCEL_ENV === 'preview' || process.env.VERCEL_ENV === 'development';
470+
}

0 commit comments

Comments
 (0)