Webpack Pack and compress ES6 files with errors: ERROR in js/xxxxxx.js from UglifyJs Unexpected token punc ()

Build project, the following error appears

ERROR in js/xxxxxx.js from UglifyJs
Unexpected token: [xxxx.js], expected: punc

It was found that uglifyjs could not resolve the problem of ES6


Upgrade uglifyjs version and modify package.json

  "uglifyjs-webpack-plugin": "^1.0.0-beta.3",


var UglifyJSPlugin = require('uglifyjs-webpack-plugin')
# Modify the plugin in plugins
        new UglifyJSPlugin({
          uglifyOptions: {
            compress: {
              drop_debugger: true, // Note debugger
              drop_console: true, // Note console
              pure_funcs:['console.log'] // remove console
          sourceMap: false,   // Removing the .map file generated after packaging
          parallel: true,

Runnpm run build, Done!

Read More: