`warnings` 不是受支持的选项,来自 UglifyJs 的错误

`warnings` is not a supported option, Error from UglifyJs

building for production...[ Error: static/js/0.e5262afb6d92aae69c76.js from UglifyJs
  `warnings` is not a supported option
      at Function.buildError (/mypath/node_modules/_uglifyjs-webpack-plugin@2.0.1@uglifyjs-webpack-plugin/dist/index.js:114:12)
      at results.forEach (/mypath/node_modules/_uglifyjs-webpack-plugin@2.0.1@uglifyjs-webpack-plugin/dist/index.js:255:52)
      at Array.forEach (<anonymous>)
      at taskRunner.run (/mypath/node_modules/_uglifyjs-webpack-plugin@2.0.1@uglifyjs-webpack-plugin/dist/index.js:242:17)
      at step (/mypath/node_modules/_uglifyjs-webpack-plugin@2.0.1@uglifyjs-webpack-plugin/dist/TaskRunner.js:76:9)
      at done (/mypath/node_modules/_uglifyjs-webpack-plugin@2.0.1@uglifyjs-webpack-plugin/dist/TaskRunner.js:84:30)
      at boundWorkers (/mypath/node_modules/_uglifyjs-webpack-plugin@2.0.1@uglifyjs-webpack-plugin/dist/TaskRunner.js:89:13)
      at /mypath/node_modules/_worker-farm@1.7.0@worker-farm/lib/farm.js:199:19
      at process._tickCallback (internal/process/next_tick.js:61:11),
  Error: static/js/1.89c4c336d047e363641c.js from UglifyJs

今天npm run build时出现此错误,

4 天前一切正常。

今天更新我的本地 node_modules,它恰好发生了。

我觉得应该是前几天发布了新版本的某个包

如有任何帮助,我们将不胜感激!


更新

此错误由上一版本uglify-js@3.5.10引起, 去掉options中的warnings可以暂时修复这个错误。

    uglifyOptions: {
          compress: {
                warnings: false,
                pure_funcs: ['console.log']
          }
    }

Uglify-js升级导致,详见:https://github.com/mishoo/UglifyJS2/issues/3394

解决方案是:

使用:

{
    "warnings": value
}

而不是:

{
    "compress": {
        "warnings": value
    }
}