@@ -426,6 +426,76 @@ describe('Sentry webpack plugin config', () => {
426
426
} ) ;
427
427
} ) ;
428
428
429
+ describe ( "Sentry webpack plugin `include` option with basePath filled on next's config" , ( ) => {
430
+ const userNextConfigWithBasePath = {
431
+ ...userNextConfig ,
432
+ basePath : '/city-park' ,
433
+ } ;
434
+
435
+ it ( 'has the correct value when building client bundles' , async ( ) => {
436
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
437
+ userNextConfig : userNextConfigWithBasePath ,
438
+ incomingWebpackConfig : clientWebpackConfig ,
439
+ incomingWebpackBuildContext : getBuildContext ( 'client' , userNextConfigWithBasePath ) ,
440
+ } ) ;
441
+
442
+ const sentryWebpackPlugin = finalWebpackConfig . plugins ?. [ 0 ] as SentryWebpackPluginType ;
443
+
444
+ expect ( sentryWebpackPlugin . options ?. include ) . toEqual ( [
445
+ { paths : [ '.next/static/chunks/pages' ] , urlPrefix : '~/city-park/_next/static/chunks/pages' } ,
446
+ ] ) ;
447
+ } ) ;
448
+
449
+ it ( 'has the correct value when building serverless server bundles' , async ( ) => {
450
+ const userNextConfigServerless = { ...userNextConfigWithBasePath } ;
451
+ userNextConfigServerless . target = 'experimental-serverless-trace' ;
452
+
453
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
454
+ userNextConfig : userNextConfigServerless ,
455
+ incomingWebpackConfig : serverWebpackConfig ,
456
+ incomingWebpackBuildContext : getBuildContext ( 'server' , userNextConfigServerless ) ,
457
+ } ) ;
458
+
459
+ const sentryWebpackPlugin = finalWebpackConfig . plugins ?. [ 0 ] as SentryWebpackPluginType ;
460
+
461
+ expect ( sentryWebpackPlugin . options ?. include ) . toEqual ( [
462
+ { paths : [ '.next/serverless/' ] , urlPrefix : '~/city-park/_next/serverless' } ,
463
+ ] ) ;
464
+ } ) ;
465
+
466
+ it ( 'has the correct value when building serverful server bundles using webpack 4' , async ( ) => {
467
+ const serverBuildContextWebpack4 = getBuildContext ( 'server' , userNextConfigWithBasePath ) ;
468
+ serverBuildContextWebpack4 . webpack . version = '4.15.13' ;
469
+
470
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
471
+ userNextConfig : userNextConfigWithBasePath ,
472
+ incomingWebpackConfig : serverWebpackConfig ,
473
+ incomingWebpackBuildContext : serverBuildContextWebpack4 ,
474
+ } ) ;
475
+
476
+ const sentryWebpackPlugin = finalWebpackConfig . plugins ?. [ 0 ] as SentryWebpackPluginType ;
477
+
478
+ expect ( sentryWebpackPlugin . options ?. include ) . toEqual ( [
479
+ { paths : [ '.next/server/pages/' ] , urlPrefix : '~/city-park/_next/server/pages' } ,
480
+ ] ) ;
481
+ } ) ;
482
+
483
+ it ( 'has the correct value when building serverful server bundles using webpack 5' , async ( ) => {
484
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
485
+ userNextConfig : userNextConfigWithBasePath ,
486
+ incomingWebpackConfig : serverWebpackConfig ,
487
+ incomingWebpackBuildContext : getBuildContext ( 'server' , userNextConfigWithBasePath ) ,
488
+ } ) ;
489
+
490
+ const sentryWebpackPlugin = finalWebpackConfig . plugins ?. [ 0 ] as SentryWebpackPluginType ;
491
+
492
+ expect ( sentryWebpackPlugin . options ?. include ) . toEqual ( [
493
+ { paths : [ '.next/server/pages/' ] , urlPrefix : '~/city-park/_next/server/pages' } ,
494
+ { paths : [ '.next/server/chunks/' ] , urlPrefix : '~/city-park/_next/server/chunks' } ,
495
+ ] ) ;
496
+ } ) ;
497
+ } ) ;
498
+
429
499
it ( 'allows SentryWebpackPlugin to be turned off for client code (independent of server code)' , ( ) => {
430
500
const clientFinalNextConfig = materializeFinalNextConfig ( {
431
501
...userNextConfig ,
0 commit comments