@@ -275,4 +275,43 @@ describe('Sentry webpack plugin config', () => {
275275 it ( "merges default include and ignore/ignoreFile options with user's values" , ( ) => {
276276 // do we even want to do this?
277277 } ) ;
278+
279+ it ( 'allows SentryWebpackPlugin to be turned off for client code (independent of server code)' , ( ) => {
280+ const clientFinalNextConfig = materializeFinalNextConfig ( {
281+ ...userNextConfig ,
282+ sentry : { disableClientWebpackPlugin : true } ,
283+ } ) ;
284+ const clientFinalWebpackConfig = clientFinalNextConfig . webpack ?.( clientWebpackConfig , clientBuildContext ) ;
285+
286+ const serverFinalNextConfig = materializeFinalNextConfig ( userNextConfig , userSentryWebpackPluginConfig ) ;
287+ const serverFinalWebpackConfig = serverFinalNextConfig . webpack ?.( serverWebpackConfig , serverBuildContext ) ;
288+
289+ expect ( clientFinalWebpackConfig ?. plugins ) . not . toEqual ( expect . arrayContaining ( [ expect . any ( SentryWebpackPlugin ) ] ) ) ;
290+ expect ( serverFinalWebpackConfig ?. plugins ) . toEqual ( expect . arrayContaining ( [ expect . any ( SentryWebpackPlugin ) ] ) ) ;
291+ } ) ;
292+
293+ it ( 'allows SentryWebpackPlugin to be turned off for server code (independent of client code)' , ( ) => {
294+ const serverFinalNextConfig = materializeFinalNextConfig ( {
295+ ...userNextConfig ,
296+ sentry : { disableServerWebpackPlugin : true } ,
297+ } ) ;
298+ const serverFinalWebpackConfig = serverFinalNextConfig . webpack ?.( serverWebpackConfig , serverBuildContext ) ;
299+
300+ const clientFinalNextConfig = materializeFinalNextConfig ( userNextConfig , userSentryWebpackPluginConfig ) ;
301+ const clientFinalWebpackConfig = clientFinalNextConfig . webpack ?.( clientWebpackConfig , clientBuildContext ) ;
302+
303+ expect ( serverFinalWebpackConfig ?. plugins ) . not . toEqual ( expect . arrayContaining ( [ expect . any ( SentryWebpackPlugin ) ] ) ) ;
304+ expect ( clientFinalWebpackConfig ?. plugins ) . toEqual ( expect . arrayContaining ( [ expect . any ( SentryWebpackPlugin ) ] ) ) ;
305+ } ) ;
306+
307+ it ( "doesn't set devtool if webpack plugin is disabled" , ( ) => {
308+ const finalNextConfig = materializeFinalNextConfig ( {
309+ ...userNextConfig ,
310+ webpack : ( ) => ( { devtool : 'something-besides-source-map' } as any ) ,
311+ sentry : { disableServerWebpackPlugin : true } ,
312+ } ) ;
313+ const finalWebpackConfig = finalNextConfig . webpack ?.( serverWebpackConfig , serverBuildContext ) ;
314+
315+ expect ( finalWebpackConfig ?. devtool ) . not . toEqual ( 'source-map' ) ;
316+ } ) ;
278317} ) ;
0 commit comments