如何从生产中删除所有console.log。此代码不适用于 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();
}
答案 0 :(得分:1)
使用laravel-mix
4.x,他们将uglify
替换为terser
(Changelog)。您必须更改 webpack.mix.js :
if (mix.inProduction()) {
mix.options({
terser: {
terserOptions: {
compress: {
drop_console: true
}
}
}
});
mix.version();
}