SyntaxError: Unexpected token: punc ())

后端 未结 2 595
野的像风
野的像风 2021-01-20 14:48

I\'m recieving:

SyntaxError: Unexpected token: punc ()) from UglifyJS

and it points to the first letter of global variable API_URL

2条回答
  •  爱一瞬间的悲伤
    2021-01-20 15:32

    Uglify doesn't fully support ES6, template literals included. You can track the conversation on Github. There's a harmony branch for ES6 support. You can use the branch by replacing your package.json entry for uglify to:

    "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony"
    

    Alternatively, you might want to pass the code through a transpiler first before minification. That way, all the syntax will be ES5 which Uglify understands very well. You might want to tweak your transpiler config if you want some of the ES6 syntax to remain intact.

提交回复
热议问题