I am trying to remove console.logs
with Webpack\'s Uglify plugin but it seems that Uglify plugin that comes bundled with Webpack doesn\'t have that option, its
I have added a comprehensive answer for webpack v4 with debug configuration
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var debug = process.env.NODE_ENV !== "production";
.....
optimization: {
minimizer: !debug ? [
new UglifyJsPlugin({
// Compression specific options
uglifyOptions: {
// Eliminate comments
comments: false,
compress: {
// remove warnings
warnings: false,
// Drop console statements
drop_console: true
},
}
})
]
: []
}
My scripts in package.json are like so:
"webpackDev": "npm run clean && export NODE_ENV=development && npx webpack",
"webpackProd": "npm run clean && export NODE_ENV=production && npx webpack -p"