@@ -295,6 +295,89 @@ describe('Sentry webpack plugin config', () => {
295
295
} ) ;
296
296
} ) ;
297
297
298
+ describe ( 'Sentry webpack plugin `urlPrefix` option with assetPrefix set' , ( ) => {
299
+ it ( 'has the correct value given a path' , async ( ) => {
300
+ const exportedNextConfigWithAssetPrefix = {
301
+ ...exportedNextConfig ,
302
+ assetPrefix : '/asset-prefix' ,
303
+ } ;
304
+ const buildContext = getBuildContext ( 'client' , exportedNextConfigWithAssetPrefix ) ;
305
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
306
+ exportedNextConfig : exportedNextConfigWithAssetPrefix ,
307
+ incomingWebpackConfig : clientWebpackConfig ,
308
+ incomingWebpackBuildContext : buildContext ,
309
+ } ) ;
310
+
311
+ const sentryWebpackPluginInstance = findWebpackPlugin (
312
+ finalWebpackConfig ,
313
+ 'SentryCliPlugin' ,
314
+ ) as SentryWebpackPlugin ;
315
+
316
+ expect ( sentryWebpackPluginInstance . options . urlPrefix ) . toEqual ( '~/asset-prefix/_next' ) ;
317
+ } ) ;
318
+
319
+ it ( 'has the correct value given a path with a leading slash' , async ( ) => {
320
+ const exportedNextConfigWithAssetPrefix = {
321
+ ...exportedNextConfig ,
322
+ assetPrefix : '/asset-prefix/' ,
323
+ } ;
324
+ const buildContext = getBuildContext ( 'client' , exportedNextConfigWithAssetPrefix ) ;
325
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
326
+ exportedNextConfig : exportedNextConfigWithAssetPrefix ,
327
+ incomingWebpackConfig : clientWebpackConfig ,
328
+ incomingWebpackBuildContext : buildContext ,
329
+ } ) ;
330
+
331
+ const sentryWebpackPluginInstance = findWebpackPlugin (
332
+ finalWebpackConfig ,
333
+ 'SentryCliPlugin' ,
334
+ ) as SentryWebpackPlugin ;
335
+
336
+ expect ( sentryWebpackPluginInstance . options . urlPrefix ) . toEqual ( '~/asset-prefix/_next' ) ;
337
+ } ) ;
338
+
339
+ it ( 'has the correct value when given a full URL' , async ( ) => {
340
+ const exportedNextConfigWithAssetPrefix = {
341
+ ...exportedNextConfig ,
342
+ assetPrefix : 'https://cdn.mydomain.com/asset-prefix' ,
343
+ } ;
344
+ const buildContext = getBuildContext ( 'client' , exportedNextConfigWithAssetPrefix ) ;
345
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
346
+ exportedNextConfig : exportedNextConfigWithAssetPrefix ,
347
+ incomingWebpackConfig : clientWebpackConfig ,
348
+ incomingWebpackBuildContext : buildContext ,
349
+ } ) ;
350
+
351
+ const sentryWebpackPluginInstance = findWebpackPlugin (
352
+ finalWebpackConfig ,
353
+ 'SentryCliPlugin' ,
354
+ ) as SentryWebpackPlugin ;
355
+
356
+ expect ( sentryWebpackPluginInstance . options . urlPrefix ) . toEqual ( '~/asset-prefix/_next' ) ;
357
+ } ) ;
358
+
359
+ it ( 'takes priority over basePath ' , async ( ) => {
360
+ const exportedNextConfigWithAssetPrefix = {
361
+ ...exportedNextConfig ,
362
+ assetPrefix : '/asset-prefix' ,
363
+ basePath : '/base-path' ,
364
+ } ;
365
+ const buildContext = getBuildContext ( 'client' , exportedNextConfigWithAssetPrefix ) ;
366
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
367
+ exportedNextConfig : exportedNextConfigWithAssetPrefix ,
368
+ incomingWebpackConfig : clientWebpackConfig ,
369
+ incomingWebpackBuildContext : buildContext ,
370
+ } ) ;
371
+
372
+ const sentryWebpackPluginInstance = findWebpackPlugin (
373
+ finalWebpackConfig ,
374
+ 'SentryCliPlugin' ,
375
+ ) as SentryWebpackPlugin ;
376
+
377
+ expect ( sentryWebpackPluginInstance . options . urlPrefix ) . toEqual ( '~/asset-prefix/_next' ) ;
378
+ } ) ;
379
+ } ) ;
380
+
298
381
describe ( 'SentryWebpackPlugin enablement' , ( ) => {
299
382
let processEnvBackup : typeof process . env ;
300
383
0 commit comments