@@ -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 ,
@@ -36,6 +37,7 @@ export { SentryWebpackPlugin };
36
37
export function constructWebpackConfigFunction (
37
38
userNextConfig : Partial < NextConfigObject > = { } ,
38
39
userSentryWebpackPluginOptions : Partial < SentryWebpackPluginOptions > = { } ,
40
+ userSentryOptions : UserSentryOptions = { } ,
39
41
) : WebpackConfigFunction {
40
42
// Will be called by nextjs and passed its default webpack configuration and context data about the build (whether
41
43
// we're building server or client, whether we're in dev, what version of webpack we're using, etc). Note that
@@ -93,9 +95,7 @@ export function constructWebpackConfigFunction(
93
95
// with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users
94
96
// try to build their apps.)
95
97
ensureCLIBinaryExists ( ) &&
96
- ( isServer
97
- ? ! userNextConfig . sentry ?. disableServerWebpackPlugin
98
- : ! userNextConfig . sentry ?. disableClientWebpackPlugin ) ;
98
+ ( isServer ? ! userSentryOptions . disableServerWebpackPlugin : ! userSentryOptions . disableClientWebpackPlugin ) ;
99
99
100
100
if ( enableWebpackPlugin ) {
101
101
// TODO Handle possibility that user is using `SourceMapDevToolPlugin` (see
@@ -109,12 +109,14 @@ export function constructWebpackConfigFunction(
109
109
// the browser won't look for them and throw errors into the console when it can't find them. Because this is a
110
110
// front-end-only problem, and because `sentry-cli` handles sourcemaps more reliably with the comment than
111
111
// without, the option to use `hidden-source-map` only applies to the client-side build.
112
- newConfig . devtool = userNextConfig . sentry ? .hideSourceMaps && ! isServer ? 'hidden-source-map' : 'source-map' ;
112
+ newConfig . devtool = userSentryOptions . hideSourceMaps && ! isServer ? 'hidden-source-map' : 'source-map' ;
113
113
}
114
114
115
115
newConfig . plugins = newConfig . plugins || [ ] ;
116
116
newConfig . plugins . push (
117
- new SentryWebpackPlugin ( getWebpackPluginOptions ( buildContext , userSentryWebpackPluginOptions ) ) ,
117
+ new SentryWebpackPlugin (
118
+ getWebpackPluginOptions ( buildContext , userSentryWebpackPluginOptions , userSentryOptions ) ,
119
+ ) ,
118
120
) ;
119
121
}
120
122
@@ -286,6 +288,7 @@ function shouldAddSentryToEntryPoint(entryPointName: string, isServer: boolean):
286
288
export function getWebpackPluginOptions (
287
289
buildContext : BuildContext ,
288
290
userPluginOptions : Partial < SentryWebpackPluginOptions > ,
291
+ userSentryOptions : UserSentryOptions ,
289
292
) : SentryWebpackPluginOptions {
290
293
const { buildId, isServer, webpack, config : userNextConfig , dev : isDev , dir : projectDir } = buildContext ;
291
294
const distDir = userNextConfig . distDir ?? '.next' ; // `.next` is the default directory
@@ -301,14 +304,14 @@ export function getWebpackPluginOptions(
301
304
isWebpack5 ? [ { paths : [ `${ distDir } /server/chunks/` ] , urlPrefix : `${ urlPrefix } /server/chunks` } ] : [ ] ,
302
305
) ;
303
306
304
- const clientInclude = userNextConfig . sentry ? .widenClientFileUpload
307
+ const clientInclude = userSentryOptions . widenClientFileUpload
305
308
? [ { paths : [ `${ distDir } /static/chunks` ] , urlPrefix : `${ urlPrefix } /static/chunks` } ]
306
309
: [ { paths : [ `${ distDir } /static/chunks/pages` ] , urlPrefix : `${ urlPrefix } /static/chunks/pages` } ] ;
307
310
308
311
const defaultPluginOptions = dropUndefinedKeys ( {
309
312
include : isServer ? serverInclude : clientInclude ,
310
313
ignore :
311
- isServer || ! userNextConfig . sentry ? .widenClientFileUpload
314
+ isServer || ! userSentryOptions . widenClientFileUpload
312
315
? [ ]
313
316
: // Widening the upload scope is necessarily going to lead to us uploading files we don't need to (ones which
314
317
// don't include any user code). In order to lessen that where we can, exclude the internal nextjs files we know
0 commit comments