@@ -42,6 +42,7 @@ export function constructWebpackConfigFunction(
4242 // we're building server or client, whether we're in dev, what version of webpack we're using, etc). Note that
4343 // `incomingConfig` and `buildContext` are referred to as `config` and `options` in the nextjs docs.
4444 const newWebpackFunction = ( incomingConfig : WebpackConfigObject , buildContext : BuildContext ) : WebpackConfigObject => {
45+ const { isServer, dev : isDev } = buildContext ;
4546 let newConfig = { ...incomingConfig } ;
4647
4748 // if user has custom webpack config (which always takes the form of a function), run it so we have actual values to
@@ -70,7 +71,7 @@ export function constructWebpackConfigFunction(
7071 // with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users
7172 // try to build their apps.)
7273 ensureCLIBinaryExists ( ) &&
73- ( buildContext . isServer
74+ ( isServer
7475 ? ! userNextConfig . sentry ?. disableServerWebpackPlugin
7576 : ! userNextConfig . sentry ?. disableClientWebpackPlugin ) ;
7677
@@ -80,14 +81,13 @@ export function constructWebpackConfigFunction(
8081
8182 // Next doesn't let you change `devtool` in dev even if you want to, so don't bother trying - see
8283 // https://github.com/vercel/next.js/blob/master/errors/improper-devtool.md
83- if ( ! buildContext . dev ) {
84+ if ( ! isDev ) {
8485 // `hidden-source-map` produces the same sourcemaps as `source-map`, but doesn't include the `sourceMappingURL`
8586 // comment at the bottom. For folks who aren't publicly hosting their sourcemaps, this is helpful because then
8687 // the browser won't look for them and throw errors into the console when it can't find them. Because this is a
8788 // front-end-only problem, and because `sentry-cli` handles sourcemaps more reliably with the comment than
8889 // without, the option to use `hidden-source-map` only applies to the client-side build.
89- newConfig . devtool =
90- userNextConfig . sentry ?. hideSourceMaps && ! buildContext . isServer ? 'hidden-source-map' : 'source-map' ;
90+ newConfig . devtool = userNextConfig . sentry ?. hideSourceMaps && ! isServer ? 'hidden-source-map' : 'source-map' ;
9191 }
9292
9393 newConfig . plugins = newConfig . plugins || [ ] ;
0 commit comments