Use BabiliPlugin() instead of UglifyJs()
[issue link]version
- nuxt 0.9.9
- element-ui 1.2.3
Error Reason
ERROR in 0.console.js from UglifyJs
Unexpected token name «i», expected punc «;» [0.console.js:2128,11]
So I look up the source file 0.console.js, I found the source file is element-ui/src/utils/merge.js
export default function(target) {
for (let i = 1, j = arguments.length; i < j; i++) {
let source = arguments[i] || {};
for (let prop in source) {
if (source.hasOwnProperty(prop)) {
let value = source[prop];
if (value !== undefined) {
target[prop] = value;
}
}
}
}
return target;
};
I found the let keyword. But webpack.optimize.UglifyJsPlugin unsupport ES6 grammar default.
My solution
change UglifyJsPlugin plugin
const BabiliPlugin = require('babili-webpack-plugin')
module.exports = {
build: {
extend (config, {dev}) {
if(!dev) {
config.plugins = config.plugins.filter((plugin) => plugin.constructor.name !== 'UglifyJsPlugin')
config.plugins.push(new BabiliPlugin())
}
}
}
}
@Atinux Do you have any better ideas?