LoginSignup
4
4

More than 3 years have passed since last update.

Laravel Mixで圧縮時にconsole.*を削除する

Last updated at Posted at 2019-12-01

Laravel Mixがterser-webpack-pluginの設定を中継してくれるので、
webpack.mix.jsに、以下の設定を含めておくだけでnpm run prod時にconsole.logが削除される。
npm run watchnpm run devするときには設定をスルーしてくれる。

webpack.mix.js
//console.log削除設定
mix.options({
    terser: {
        terserOptions: {
            compress: {
                drop_console: true
            }
        }
    }
});

以下バージョンで動作確認済み

package.json
"laravel-mix": "^4.1.4",

ありがたやありがたや

参考リンク

4
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4