Webpack packaging does not recognize ES6 syntax of pits

Source: Internet
Author: User

Today Vue Project NPM Run build after Webpack, error UGLIFYJS, their own research, translated, meaning is not recognized in the project to write advanced grammar, here to the project ES6 syntax es5 let the browser recognize,

That is Webpack's Babel need to be configured under

Babel is actually a platform for compiling JavaScript, and its strength is that it can be compiled to help you achieve the following:

  • Use the next generation of JavaScript code (ES6,ES7 ... ), even though these standards are not currently fully supported by the current browser;
  • Using JavaScript-based languages such as React's jsx;

1. Install the package first

NPM Install babel-preset-es2015

2. Configure Webpack.base.conf.js
{
Test:/\.js$/,
Loader: ' Babel-loader ',
options:{
presets:["es2015"]
},
Exclude:[/node_modules/]

},
3.OK, re-build the NPM Run build project package, okay.




Webpack packaging does not recognize ES6 syntax of pits

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.