diff --git a/packages/nextjs/src/config/types.ts b/packages/nextjs/src/config/types.ts index bbba80e476c8..0a188341ce58 100644 --- a/packages/nextjs/src/config/types.ts +++ b/packages/nextjs/src/config/types.ts @@ -122,7 +122,7 @@ export type SentryBuildOptions = { */ sourcemaps?: { /** - * Disable any functionality related to source maps upload. + * Disable any functionality related to source maps. */ disable?: boolean; diff --git a/packages/nextjs/src/config/webpackPluginOptions.ts b/packages/nextjs/src/config/webpackPluginOptions.ts index 43aea096bdaa..530659b2a703 100644 --- a/packages/nextjs/src/config/webpackPluginOptions.ts +++ b/packages/nextjs/src/config/webpackPluginOptions.ts @@ -23,7 +23,7 @@ export function getWebpackPluginOptions( const distDir = (userNextConfig as NextConfigObject).distDir?.replace(/\\/g, '/') ?? '.next'; const distDirAbsPath = path.posix.join(projectDir, distDir); - let sourcemapUploadAssets: string[] = []; + const sourcemapUploadAssets: string[] = []; const sourcemapUploadIgnore: string[] = []; if (isServer) { @@ -51,10 +51,6 @@ export function getWebpackPluginOptions( ); } - if (sentryBuildOptions.sourcemaps?.disable) { - sourcemapUploadAssets = []; - } - return { authToken: sentryBuildOptions.authToken, headers: sentryBuildOptions.headers, @@ -69,6 +65,7 @@ export function getWebpackPluginOptions( silent: sentryBuildOptions.silent, url: sentryBuildOptions.sentryUrl, sourcemaps: { + disable: sentryBuildOptions.sourcemaps?.disable, rewriteSources(source) { if (source.startsWith('webpack://_N_E/')) { return source.replace('webpack://_N_E/', ''); diff --git a/packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts b/packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts index d6af815d13cb..c987cda267e4 100644 --- a/packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts +++ b/packages/nextjs/test/config/webpack/webpackPluginOptions.test.ts @@ -173,11 +173,11 @@ describe('getWebpackPluginOptions()', () => { }); }); - it('sets `sourcemaps.assets` to an empty array when `sourcemaps.disable` is true', () => { + it('sets `sourcemaps.disable` plugin options to true when `sourcemaps.disable` is true', () => { const buildContext = generateBuildContext({ isServer: false }); const generatedPluginOptions = getWebpackPluginOptions(buildContext, { sourcemaps: { disable: true } }, undefined); expect(generatedPluginOptions.sourcemaps).toMatchObject({ - assets: [], + disable: true, }); });