Packing error after ElementUI upgrade, ERROR in xxx.js from UglifyJs

created at 08-23-2021 views: 3

Reason

Since UglifyJs only supports ES5 and element-ui may introduce part of ES6, the webpack packaging fails.

Solution

Use bable to parse element-ui. To complete this operation, you only need to modify the build/webpack.base.conf.js file in the front-end folder, as follows:

// before modification
rules: [
    {
      test: /\.js$/,
      loader: 'babel-loader',
      include: [resolve('src'), resolve('test')]
    }
]
// after modification
rules: [
    {
      test: /\.js$/,
      loader: 'babel-loader',
      include: [resolve('src'), resolve('test'), resolve('/node_modules/element-ui/src'), resolve('/node_modules/element-ui/packages')]
    }
]

It is equivalent to adding element-ui to the package that needs to be parsed by babel. Then execute npm run build again successfully.

created at:08-23-2021
edited at: 08-23-2021: