Webpack 4.x uglifyjs remove comments
Webpack 4.x uglifyjs remove comments
uglifyjs & uglifyjs-webpack-plugin
1. remove comments
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
// ...
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
output: {
// 2. remove comments
comments: false,
},
},
}),
],
},
}
2. preserve comments
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
// ...
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
output: {
// ✅ preserve comments
comments: true,
},
},
}),
],
},
}
preserve comments
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
// ...
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: /@license/i,
},
},
extractComments: true,
}),
],
},
};
https://v4.webpack.js.org/plugins/uglifyjs-webpack-plugin/#preserve-comments
refs
https://github.com/webpack/webpack/issues/6879#issuecomment-785867797
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14449177.html
未经授权禁止转载,违者必究!