Webpack + UglifyJs: how to ignore warnings about 3rd party library code

cachvico picture cachvico · Nov 23, 2015 · Viewed 7.4k times · Source

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?

Answer

Michael Hellein picture Michael Hellein · Dec 3, 2015

No, it's currently only possible to turn off all warnings, per the UglifyJS compressor options: https://github.com/mishoo/UglifyJS2#compressor-options

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

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
            }
        })
    ]
}