From 24caf4c515b2f958b480b2a3306c9b3e4b2dce19 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Thu, 20 Mar 2025 12:15:39 +0100 Subject: [PATCH 1/2] feat(nextjs): Disable server webpack-handling for static builds --- packages/nextjs/src/config/webpack.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index de047c0b8cf4..29a6d43d0bd8 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -341,9 +341,11 @@ export function constructWebpackConfigFunction( newConfig.entry = async () => addSentryToClientEntryProperty(origEntryProperty, buildContext); } - // We don't want to do any webpack plugin stuff OR any source maps stuff in dev mode. + const isStaticExport = userNextConfig?.output === 'export'; + + // We don't want to do any webpack plugin stuff OR any source maps stuff in dev mode or for the server on static-only builds. // Symbolication for dev-mode errors is done elsewhere. - if (!isDev) { + if (!isDev || !(isStaticExport && isServer)) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const { sentryWebpackPlugin } = loadModule<{ sentryWebpackPlugin: any }>('@sentry/webpack-plugin', module) ?? {}; From 28a592973c3e9f2db73b87b3ef9e7dbeab607a9a Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 24 Mar 2025 11:45:53 +0100 Subject: [PATCH 2/2] fix condition --- packages/nextjs/src/config/webpack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 29a6d43d0bd8..f7f06c8fa8eb 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -345,7 +345,7 @@ export function constructWebpackConfigFunction( // We don't want to do any webpack plugin stuff OR any source maps stuff in dev mode or for the server on static-only builds. // Symbolication for dev-mode errors is done elsewhere. - if (!isDev || !(isStaticExport && isServer)) { + if (!(isDev || (isStaticExport && isServer))) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const { sentryWebpackPlugin } = loadModule<{ sentryWebpackPlugin: any }>('@sentry/webpack-plugin', module) ?? {};