Skip to content

Commit

Permalink
fix(nextjs): Use webpack plugin release value to inject release (#9348)
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Oct 24, 2023
1 parent 81c9651 commit f6d66b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function constructWebpackConfigFunction(
const newConfig = setUpModuleRules(rawNewConfig);

// Add a loader which will inject code that sets global values
addValueInjectionLoader(newConfig, userNextConfig, userSentryOptions, buildContext);
addValueInjectionLoader(newConfig, userNextConfig, userSentryOptions, buildContext, userSentryWebpackPluginOptions);

newConfig.module.rules.push({
test: /node_modules[/\\]@sentry[/\\]nextjs/,
Expand Down Expand Up @@ -939,6 +939,7 @@ function addValueInjectionLoader(
userNextConfig: NextConfigObject,
userSentryOptions: UserSentryOptions,
buildContext: BuildContext,
sentryWebpackPluginOptions: Partial<SentryWebpackPluginOptions>,
): void {
const assetPrefix = userNextConfig.assetPrefix || userNextConfig.basePath || '';

Expand All @@ -951,7 +952,9 @@ function addValueInjectionLoader(

// The webpack plugin's release injection breaks the `app` directory so we inject the release manually here instead.
// Having a release defined in dev-mode spams releases in Sentry so we only set one in non-dev mode
SENTRY_RELEASE: buildContext.dev ? undefined : { id: getSentryRelease(buildContext.buildId) },
SENTRY_RELEASE: buildContext.dev
? undefined
: { id: sentryWebpackPluginOptions.release ?? getSentryRelease(buildContext.buildId) },
};

const serverValues = {
Expand Down

0 comments on commit f6d66b5

Please sign in to comment.