Webpack + UglifyJs:如何忽略关于 3rd 方库代码的警告 [英] Webpack + UglifyJs: how to ignore warnings about 3rd party library code
问题描述
使用 Webpack,我从 UglifyJSPlugin 收到了大量关于我所有 3rd 方代码的警告.
Using Webpack, I get a load of warnings from UglifyJSPlugin for all my 3rd party code.
是否可以仅关闭某些库的警告?
Is it possible to turn off warnings for some libraries only?
推荐答案
不,目前只能关闭所有警告,根据 UglifyJS 压缩器选项:https://github.com/mishoo/UglifyJS2#compressor-options
No, it's currently only possible to turn off all warnings, per the UglifyJS compressor options: https://github.com/mishoo/UglifyJS2#compressor-options
您可以通过将 UglifyJS 选项传递给 Webpack 的 UglifyJsPlugin 的构造函数来关闭所有警告:https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
You can turn off all warnings by passing UglifyJS options to the constructor for Webpack's UglifyJsPlugin: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
在你的 webpack.config.js 中,你需要有这样的东西:
In your webpack.config.js, you'd need to have something like:
var webpack = require('webpack');
module.exports = {
...
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
}
这篇关于Webpack + UglifyJs:如何忽略关于 3rd 方库代码的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!