@@ -10,6 +10,7 @@ import {
10
10
EntryPropertyObject ,
11
11
NextConfigObject ,
12
12
SentryWebpackPluginOptions ,
13
+ UserSentryOptions ,
13
14
WebpackConfigFunction ,
14
15
WebpackConfigObject ,
15
16
WebpackEntryProperty ,
@@ -37,6 +38,7 @@ export { SentryWebpackPlugin };
37
38
export function constructWebpackConfigFunction (
38
39
userNextConfig : Partial < NextConfigObject > = { } ,
39
40
userSentryWebpackPluginOptions : Partial < SentryWebpackPluginOptions > = { } ,
41
+ userSentryOptions : UserSentryOptions = { } ,
40
42
) : WebpackConfigFunction {
41
43
// Will be called by nextjs and passed its default webpack configuration and context data about the build (whether
42
44
// we're building server or client, whether we're in dev, what version of webpack we're using, etc). Note that
@@ -122,9 +124,7 @@ export function constructWebpackConfigFunction(
122
124
// with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users
123
125
// try to build their apps.)
124
126
ensureCLIBinaryExists ( ) &&
125
- ( isServer
126
- ? ! userNextConfig . sentry ?. disableServerWebpackPlugin
127
- : ! userNextConfig . sentry ?. disableClientWebpackPlugin ) ;
127
+ ( isServer ? ! userSentryOptions . disableServerWebpackPlugin : ! userSentryOptions . disableClientWebpackPlugin ) ;
128
128
129
129
if ( enableWebpackPlugin ) {
130
130
// TODO Handle possibility that user is using `SourceMapDevToolPlugin` (see
@@ -138,12 +138,14 @@ export function constructWebpackConfigFunction(
138
138
// the browser won't look for them and throw errors into the console when it can't find them. Because this is a
139
139
// front-end-only problem, and because `sentry-cli` handles sourcemaps more reliably with the comment than
140
140
// without, the option to use `hidden-source-map` only applies to the client-side build.
141
- newConfig . devtool = userNextConfig . sentry ? .hideSourceMaps && ! isServer ? 'hidden-source-map' : 'source-map' ;
141
+ newConfig . devtool = userSentryOptions . hideSourceMaps && ! isServer ? 'hidden-source-map' : 'source-map' ;
142
142
}
143
143
144
144
newConfig . plugins = newConfig . plugins || [ ] ;
145
145
newConfig . plugins . push (
146
- new SentryWebpackPlugin ( getWebpackPluginOptions ( buildContext , userSentryWebpackPluginOptions ) ) ,
146
+ new SentryWebpackPlugin (
147
+ getWebpackPluginOptions ( buildContext , userSentryWebpackPluginOptions , userSentryOptions ) ,
148
+ ) ,
147
149
) ;
148
150
}
149
151
@@ -381,6 +383,7 @@ function shouldAddSentryToEntryPoint(entryPointName: string, isServer: boolean):
381
383
export function getWebpackPluginOptions (
382
384
buildContext : BuildContext ,
383
385
userPluginOptions : Partial < SentryWebpackPluginOptions > ,
386
+ userSentryOptions : UserSentryOptions ,
384
387
) : SentryWebpackPluginOptions {
385
388
const { buildId, isServer, webpack, config : userNextConfig , dev : isDev , dir : projectDir } = buildContext ;
386
389
const distDir = userNextConfig . distDir ?? '.next' ; // `.next` is the default directory
@@ -396,14 +399,14 @@ export function getWebpackPluginOptions(
396
399
isWebpack5 ? [ { paths : [ `${ distDir } /server/chunks/` ] , urlPrefix : `${ urlPrefix } /server/chunks` } ] : [ ] ,
397
400
) ;
398
401
399
- const clientInclude = userNextConfig . sentry ? .widenClientFileUpload
402
+ const clientInclude = userSentryOptions . widenClientFileUpload
400
403
? [ { paths : [ `${ distDir } /static/chunks` ] , urlPrefix : `${ urlPrefix } /static/chunks` } ]
401
404
: [ { paths : [ `${ distDir } /static/chunks/pages` ] , urlPrefix : `${ urlPrefix } /static/chunks/pages` } ] ;
402
405
403
406
const defaultPluginOptions = dropUndefinedKeys ( {
404
407
include : isServer ? serverInclude : clientInclude ,
405
408
ignore :
406
- isServer || ! userNextConfig . sentry ? .widenClientFileUpload
409
+ isServer || ! userSentryOptions . widenClientFileUpload
407
410
? [ ]
408
411
: // Widening the upload scope is necessarily going to lead to us uploading files we don't need to (ones which
409
412
// don't include any user code). In order to lessen that where we can, exclude the internal nextjs files we know
0 commit comments