webpack-simple icon indicating copy to clipboard operation
webpack-simple copied to clipboard

"npm run build" results in error in UglifyJS

Open leonardojobim opened this issue 7 years ago • 2 comments

Executing the command "npm run build" is resulting in error in UglifyJS. It isn't able to recognize keys words like "let" and "new" and is showing error messages like below:

ERROR in build.js from UglifyJs Unexpected token: punc (() [build.js:11307,24] ERROR in build.js from UglifyJs Unexpected token: name (app)

leonardojobim avatar Dec 28 '17 18:12 leonardojobim

solve it like this

const UglifyJsPlugin = require('uglifyjs-webpack-plugin')


if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new UglifyJsPlugin({
      uglifyOptions: {        
        ecma: 8      
      }
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    })
  ])
}

AlexisSniffer avatar Dec 29 '17 03:12 AlexisSniffer

I recreated the project and it worked fine. Thank you.

leonardojobim avatar Jan 08 '18 02:01 leonardojobim