File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export type NextConfigObject = {
2020 sentry ?: {
2121 disableServerWebpackPlugin ?: boolean ;
2222 disableClientWebpackPlugin ?: boolean ;
23+ hideSourceMaps ?: boolean ;
2324 } ;
2425} & {
2526 // other `next.config.js` options
Original file line number Diff line number Diff line change @@ -77,12 +77,11 @@ export function constructWebpackConfigFunction(
7777 if ( enableWebpackPlugin ) {
7878 // TODO Handle possibility that user is using `SourceMapDevToolPlugin` (see
7979 // https://webpack.js.org/plugins/source-map-dev-tool-plugin/)
80- // TODO Give user option to use `hidden-source-map` ?
8180
8281 // Next doesn't let you change this is dev even if you want to - see
8382 // https://github.com/vercel/next.js/blob/master/errors/improper-devtool.md
8483 if ( ! buildContext . dev ) {
85- newConfig . devtool = 'source-map' ;
84+ newConfig . devtool = userNextConfig . sentry ?. hideSourceMaps ? 'hidden-source-map' : 'source-map' ;
8685 }
8786
8887 newConfig . plugins = newConfig . plugins || [ ] ;
Original file line number Diff line number Diff line change @@ -300,6 +300,19 @@ describe('webpack config', () => {
300300 expect ( finalWebpackConfig ) . toEqual ( expect . objectContaining ( materializedUserWebpackConfig ) ) ;
301301 } ) ;
302302
303+ it ( 'allows for the use of `hidden-source-map` as `devtool` value' , async ( ) => {
304+ const userNextConfigHiddenSourceMaps = { ...userNextConfig , sentry : { ...userNextConfig . sentry } } ;
305+ userNextConfigHiddenSourceMaps . sentry . hideSourceMaps = true ;
306+
307+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
308+ userNextConfig : userNextConfigHiddenSourceMaps ,
309+ incomingWebpackConfig : serverWebpackConfig ,
310+ incomingWebpackBuildContext : serverBuildContext ,
311+ } ) ;
312+
313+ expect ( finalWebpackConfig . devtool ) . toEqual ( 'hidden-source-map' ) ;
314+ } ) ;
315+
303316 describe ( 'webpack `entry` property config' , ( ) => {
304317 const serverConfigFilePath = `./${ SERVER_SDK_CONFIG_FILE } ` ;
305318 const clientConfigFilePath = `./${ CLIENT_SDK_CONFIG_FILE } ` ;
You can’t perform that action at this time.
0 commit comments