@@ -70,7 +70,7 @@ const nextConfig = {
7070 images : {
7171 domains : [ 'i3.ytimg.com' ] ,
7272 } ,
73- webpack : ( config , { isServer } ) => {
73+ webpack : ( config , { dev , isServer } ) => {
7474 // -i- Run aetherspace automation scripts in DEV mode
7575 if ( ! isServer && process . env . NODE_ENV === 'development' ) withAutomation ( )
7676 // Enable top level await in API handlers
@@ -87,6 +87,20 @@ const nextConfig = {
8787 config . plugins . push ( new FilterWarningsPlugin ( {
8888 exclude : [ / t h e r e q u e s t o f a d e p e n d e n c y i s a n e x p r e s s i o n / ] ,
8989 } ) )
90+ // Uncomment these lines to debug with console logs during `next build`
91+ if ( ! dev && ! isServer ) {
92+ config . optimization . minimizer = config . optimization . minimizer . map ( plugin => {
93+ if ( plugin . constructor . name === 'TerserPlugin' ) {
94+ plugin . options . terserOptions = {
95+ ...plugin . options . terserOptions ,
96+ // Prevent discarding or mangling of console statements
97+ compress : { ...plugin . options . terserOptions . compress , drop_console : false } ,
98+ mangle : { ...plugin . options . terserOptions . mangle , reserved : [ 'console' ] } ,
99+ }
100+ }
101+ return plugin ;
102+ } )
103+ }
90104 // Return config
91105 return config
92106 } ,
0 commit comments