鍍金池/ 問答/HTML/ webpack 的 UglifyJSPlugin 一填參數(shù)就報錯,怎么解決?

webpack 的 UglifyJSPlugin 一填參數(shù)就報錯,怎么解決?

正常運行的部分代碼:

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
plugins: [
    new UglifyJSPlugin()
]

但是我一但給UglifyJSPlugin添加配置信息,運行就會報錯,比如:

plugins: [
    new UglifyJSPlugin({
        warnings: false
    })
]

無論填什么都報錯,不知道哪兒出問題了,求大神指點。
報錯信息:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webpack02@1.0.0 pack: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack02@1.0.0 pack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     e:\tools\Roaming\npm-cache\_logs\2017-11-21T03_11_35_179Z-debug.log
回答
編輯回答
兔寶寶

npm uninstall webpack --save-dev
npm install webpack@3.6.0 --save-dev
我是使用3.6的版本解決了

2017年9月2日 19:04
編輯回答
青裙
[
  new UglifyJsPlugin({
    uglifyOptions: {
      ie8: false,
      ecma: 8,
      parse: {...options},
      mangle: {
        ...options,
        properties: {
          // mangle property options
        }
      },
      output: {
        comments: false,
        beautify: false,
        ...options
      },
      compress: {...options},
      warnings: false
    }
  })
]

試試這樣,還有把報錯信息貼出來看看


webpack -h

看看 webpack 有沒有裝成功

2018年5月6日 07:27