Home  >  Q&A  >  body text

javascript - webpack packaging error

When using webpack2.x to package, the following error occurs (Unexpected token name «i», expected punc «;»):

ERROR in app.js from UglifyJs
Unexpected token name «i», expected punc «;» [app.js:9461,13]

The error reported is:

function oneOf (value, validList) {
    for (let i = 0; i < validList.length; i++) {//此行报错
        if (value === validList[i]) {
            return true;
        }
    }
    return false;
}

It seems that the UglifyJs compression plug-in made an error when encountering es6 syntax. However, the code I wrote in the project was compiled with babel, and the code reporting the error above should come from the vue library. Why are these codes not compiled by babel before performing UglifyJs compression?

给我你的怀抱给我你的怀抱2710 days ago873

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-06-12 09:33:13

    This is the code in iView. Does the babel configured by webpack ignore the iView directory because it is in node_modules. For the correct configuration, please see https://github.com/iview/ivie...

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-12 09:33:13

    What is your node version? node -VTake a look

    reply
    0
  • Cancelreply