无法在webpack bundle js文件中删除注释
我一直试图在webpack捆绑的js文件中删除注释。
我尝试了几种方法,但它还没有工作,我收到的评论就像
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\ ...
为此,捆绑的文件变得越来越大。目前大小为1.6mb。
我试过这个
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
}
})
此
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
sourceMap: false,
output: false
})
同时将环境设置为生产
set NODE_ENV=production
请帮忙。
提前致谢。
I am not able to understand where I am wrong. Please help. Thanks in advance.
UglifyJsPlugin
不要即使您出于法律原因设置 comments:false
,也要删除 @licence
条评论。你可以在关于webpack GitHub问题上阅读它。
UglifyJsPlugin
don't remove @licence
comments even if you set comments: false
for legal reasons. You can read about it on webpack GitHub issue.
如果您想删除此类评论(风险自负),您应该搜索其他加载器,例如 webpack-comment-remover-loader
或 stripcomment-loader
。
If you want to remove this kind of comments (on your own risk) you should search for other loaders like webpack-comment-remover-loader
or stripcomment-loader
.