Skip to content

fix(nextjs): Use webpack plugin release value to inject release #9348

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

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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