Skip to content

Commit d9562b9

Browse files
author
Luca Forstner
authored
fix(nextjs): Do not hide sourceMappingURL comment on client when nextConfig.productionBrowserSourceMaps: true is set (#12278)
1 parent 0d1093d commit d9562b9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/nextjs/src/config/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export type NextConfigObject = {
4848
instrumentationHook?: boolean;
4949
clientTraceMetadata?: string[];
5050
};
51+
productionBrowserSourceMaps?: boolean;
5152
};
5253

5354
export type SentryBuildOptions = {

packages/nextjs/src/config/webpack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ export function constructWebpackConfigFunction(
329329
// the browser won't look for them and throw errors into the console when it can't find them. Because this is a
330330
// front-end-only problem, and because `sentry-cli` handles sourcemaps more reliably with the comment than
331331
// without, the option to use `hidden-source-map` only applies to the client-side build.
332-
newConfig.devtool = !isServer ? 'hidden-source-map' : 'source-map';
332+
newConfig.devtool =
333+
isServer || userNextConfig.productionBrowserSourceMaps ? 'source-map' : 'hidden-source-map';
333334
}
334335

335336
newConfig.plugins = newConfig.plugins || [];

0 commit comments

Comments
 (0)