@@ -261,4 +261,43 @@ describe('Sentry webpack plugin config', () => {
261261 it ( "merges default include and ignore/ignoreFile options with user's values" , ( ) => {
262262 // do we even want to do this?
263263 } ) ;
264+
265+ it ( 'allows SentryWebpackPlugin to be turned off for client code (independent of server code)' , ( ) => {
266+ const clientFinalNextConfig = materializeFinalNextConfig ( {
267+ ...userNextConfig ,
268+ sentry : { disableClientWebpackPlugin : true } ,
269+ } ) ;
270+ const clientFinalWebpackConfig = clientFinalNextConfig . webpack ?.( clientWebpackConfig , clientBuildContext ) ;
271+
272+ const serverFinalNextConfig = materializeFinalNextConfig ( userNextConfig , userSentryWebpackPluginConfig ) ;
273+ const serverFinalWebpackConfig = serverFinalNextConfig . webpack ?.( serverWebpackConfig , serverBuildContext ) ;
274+
275+ expect ( clientFinalWebpackConfig ?. plugins ) . not . toEqual ( expect . arrayContaining ( [ expect . any ( SentryWebpackPlugin ) ] ) ) ;
276+ expect ( serverFinalWebpackConfig ?. plugins ) . toEqual ( expect . arrayContaining ( [ expect . any ( SentryWebpackPlugin ) ] ) ) ;
277+ } ) ;
278+
279+ it ( 'allows SentryWebpackPlugin to be turned off for server code (independent of client code)' , ( ) => {
280+ const serverFinalNextConfig = materializeFinalNextConfig ( {
281+ ...userNextConfig ,
282+ sentry : { disableServerWebpackPlugin : true } ,
283+ } ) ;
284+ const serverFinalWebpackConfig = serverFinalNextConfig . webpack ?.( serverWebpackConfig , serverBuildContext ) ;
285+
286+ const clientFinalNextConfig = materializeFinalNextConfig ( userNextConfig , userSentryWebpackPluginConfig ) ;
287+ const clientFinalWebpackConfig = clientFinalNextConfig . webpack ?.( clientWebpackConfig , clientBuildContext ) ;
288+
289+ expect ( serverFinalWebpackConfig ?. plugins ) . not . toEqual ( expect . arrayContaining ( [ expect . any ( SentryWebpackPlugin ) ] ) ) ;
290+ expect ( clientFinalWebpackConfig ?. plugins ) . toEqual ( expect . arrayContaining ( [ expect . any ( SentryWebpackPlugin ) ] ) ) ;
291+ } ) ;
292+
293+ it ( "doesn't set devtool if webpack plugin is disabled" , ( ) => {
294+ const finalNextConfig = materializeFinalNextConfig ( {
295+ ...userNextConfig ,
296+ webpack : ( ) => ( { devtool : 'something-besides-source-map' } as any ) ,
297+ sentry : { disableServerWebpackPlugin : true } ,
298+ } ) ;
299+ const finalWebpackConfig = finalNextConfig . webpack ?.( serverWebpackConfig , serverBuildContext ) ;
300+
301+ expect ( finalWebpackConfig ?. devtool ) . not . toEqual ( 'source-map' ) ;
302+ } ) ;
264303} ) ;
0 commit comments