UglifyJs Unexpected token: punc problem occurs when vue+element-ui is packaged

It appeared when I packaged the vue+element-ui packaging project yesterday

ERROR in static/js/vendor.1c5ad0ffe5abfcdf0af6.js from UglifyJs
Unexpected token: punc (() [./~/.1.4.2@element-ui/packages/row/src/row.js:24,0][static/js/vendor.1c5ad0ffe5abfcdf0af6.js:11183,9]

question

I have been using Vue's scaffolding for packaging and generation before, and it has been fine. I don't know why this problem occurred after two months of not playing.

Baidu's.

It is found that UglifyJs cannot parse ES6, and the package in 1.4.2 element-ui is estimated to have ES6 syntax, so the packaging fails. After searching for a long time, I found a solution, which is to let babel parse when packaging. failed package

Revise

-build
    --webpack.base.conf.js

Find the module that parses js:
it turns out:

 module: {
    rules: [
     ...
      {
        test: /\.js$/,
        loader: 'babel-loader',//注意elementUI的源码使用ES6需要解析
        include: [resolve('src'), resolve('test')]
      },
      ...

after modification

 module: {
   ...
      {
        test: /\.js$/,
        loader: 'babel-loader',//注意elementUI的源码使用ES6需要解析,注意,这里不要直接复制,还需要改element ui对应的版本号
        include: [resolve('src'), resolve('test'),resolve('/node_modules/.1.4.2@element-ui/src'),resolve('/node_modules/.1.4.2@element-ui/packages')]
      },
      ...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326131712&siteId=291194637