I have been trying to strip comments in the webpack bundled js file. I have tried several methods but it's not working still and I get comments like
"/**\n * Copyright 2013-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\ ...
For this the bundled file is getting huge. Currently huge at 1.6mb size. I have tried this
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
},
mangle: {
except: ['$super', '$', 'exports', 'require']
},
output: {
comments: false
}
})
also this
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
sourceMap: false,
output: false
})
Also set the enviroment to production
set NODE_ENV=production
I am not able to understand where I am wrong. Please help. Thanks in advance.
For webpack 4 this was working for me:
// webpack.config.js
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
// other config properties...
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false
}
}
})
]
}
};
You can find more information in the official docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With