Skip to content

Commit f6d66b5

Browse files
author
Luca Forstner
authored
fix(nextjs): Use webpack plugin release value to inject release (#9348)
1 parent 81c9651 commit f6d66b5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function constructWebpackConfigFunction(
8181
const newConfig = setUpModuleRules(rawNewConfig);
8282

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

8686
newConfig.module.rules.push({
8787
test: /node_modules[/\\]@sentry[/\\]nextjs/,
@@ -939,6 +939,7 @@ function addValueInjectionLoader(
939939
userNextConfig: NextConfigObject,
940940
userSentryOptions: UserSentryOptions,
941941
buildContext: BuildContext,
942+
sentryWebpackPluginOptions: Partial<SentryWebpackPluginOptions>,
942943
): void {
943944
const assetPrefix = userNextConfig.assetPrefix || userNextConfig.basePath || '';
944945

@@ -951,7 +952,9 @@ function addValueInjectionLoader(
951952

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

957960
const serverValues = {

0 commit comments

Comments
 (0)