简体   繁体   中英

Webpack UglifyJsPlugin Error when nonuse sourceMap

I know UglifyJsPlugin do not support ES6 , so there has some problems when ES6 transform to ES5

In production env Error: Unexpected token punc «,», expected punc «:» [bundle.js:2808,8]

new webpack.optimize.UglifyJsPlugin({
    output: {
        comments: false
    }
})

But It's OK In development env

new webpack.optimize.UglifyJsPlugin({
    sourceMap: true,
    output: {
        comments: false
    }
})

Webpack v2.4.1 and babel v6.5.2 Webpack presets: ["es2015","stage-0","react"]

The screenshot of error : enter image description here

Finally, I find the code what I post is not ES6, while it follow the CMD principle. That code Webpack will not transform and UglifyJsPlugin can't transform.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM