Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove console.log from production?

Tags:

laravel-mix

How can I remove all console.log from production. This code isn't working on laravel-mix 4.x:

webpack.mix.js

mix
    .js('resources/js/app.js', 'public/js')

if (mix.inProduction()) {
    mix.options({
      uglify: {
        uglifyOptions: {
          warnings: false,
          comments: false,
          beautify: false,
          compress: {
            drop_console: true,
          }
        }
      }
    });

    mix.version();
}
like image 298
poldixd Avatar asked Dec 10 '22 04:12

poldixd


1 Answers

With laravel-mix 4.x they replaced uglify with terser (Changelog). You have to change your webpack.mix.js:

if (mix.inProduction()) {
    mix.options({
        terser: {
            terserOptions: {
                compress: {
                   drop_console: true
                }
            }
        }
    });

    mix.version();
}
like image 108
poldixd Avatar answered Mar 23 '23 11:03

poldixd