@@ -42,6 +42,7 @@ export function constructWebpackConfigFunction(
42
42
// we're building server or client, whether we're in dev, what version of webpack we're using, etc). Note that
43
43
// `incomingConfig` and `buildContext` are referred to as `config` and `options` in the nextjs docs.
44
44
const newWebpackFunction = ( incomingConfig : WebpackConfigObject , buildContext : BuildContext ) : WebpackConfigObject => {
45
+ const { isServer, dev : isDev } = buildContext ;
45
46
let newConfig = { ...incomingConfig } ;
46
47
47
48
// 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(
70
71
// with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users
71
72
// try to build their apps.)
72
73
ensureCLIBinaryExists ( ) &&
73
- ( buildContext . isServer
74
+ ( isServer
74
75
? ! userNextConfig . sentry ?. disableServerWebpackPlugin
75
76
: ! userNextConfig . sentry ?. disableClientWebpackPlugin ) ;
76
77
@@ -80,14 +81,13 @@ export function constructWebpackConfigFunction(
80
81
81
82
// Next doesn't let you change `devtool` in dev even if you want to, so don't bother trying - see
82
83
// https://github.com/vercel/next.js/blob/master/errors/improper-devtool.md
83
- if ( ! buildContext . dev ) {
84
+ if ( ! isDev ) {
84
85
// `hidden-source-map` produces the same sourcemaps as `source-map`, but doesn't include the `sourceMappingURL`
85
86
// comment at the bottom. For folks who aren't publicly hosting their sourcemaps, this is helpful because then
86
87
// the browser won't look for them and throw errors into the console when it can't find them. Because this is a
87
88
// front-end-only problem, and because `sentry-cli` handles sourcemaps more reliably with the comment than
88
89
// 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' ;
91
91
}
92
92
93
93
newConfig . plugins = newConfig . plugins || [ ] ;
0 commit comments