webpack-simple
webpack-simple copied to clipboard
"npm run build" results in error in UglifyJS
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)
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
})
])
}
I recreated the project and it worked fine. Thank you.