javascript - UglifyJs unexpected token error - Stack Overflow

I have already used this in my webpack.config.js use: [{loader: 'babel-loader',options: {pres

I have already used this in my webpack.config.js

use: [{
        loader: 'babel-loader',
        options: {
          presets: ['es2015', 'es2016', 'react']
        }
      }]

But still I am getting error at the token let which I have used.

I get that uglify doesn't understands ECMAScript-6

Now when i build my webpack with -p, i get the mentioned error, because uglify es up there. Now, how can i solve this problem as I have already included babel-loader preset es2015 to convert es6 to es5.

I have already used this in my webpack.config.js

use: [{
        loader: 'babel-loader',
        options: {
          presets: ['es2015', 'es2016', 'react']
        }
      }]

But still I am getting error at the token let which I have used.

I get that uglify doesn't understands ECMAScript-6

Now when i build my webpack with -p, i get the mentioned error, because uglify es up there. Now, how can i solve this problem as I have already included babel-loader preset es2015 to convert es6 to es5.

Share Improve this question asked Mar 18, 2018 at 12:10 ANURAG GUPTAANURAG GUPTA 1931 silver badge13 bronze badges 3
  • Can you tell us what is the error text you are getting at the token let ? – S Raghav Commented Mar 18, 2018 at 12:26
  • UglifyJs failure, Unexpected token error: name (xyz) @raghav710 – ANURAG GUPTA Commented Mar 18, 2018 at 14:54
  • I have fixed the issue as described in the following thread stackoverflow./questions/61606913/… – Julian Eduardo de Anquin Commented Jan 22, 2021 at 13:24
Add a ment  | 

2 Answers 2

Reset to default 3

As you've said, your current version of the Uglify plugin doesn't support ES6, so you'll need to upgrade. You have a few options:

  1. Upgrade to Webpack 4, which includes the new uglify plugin by default
  2. If you need to stay on v3 for whatever reason, you can follow the instructions on the docs here to install the new uglify plugin and use it manually.

Use terser-webpack-plugin for minifying ES6 code

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745280234a4620244.html

相关推荐

  • javascript - UglifyJs unexpected token error - Stack Overflow

    I have already used this in my webpack.config.js use: [{loader: 'babel-loader',options: {pres

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信