Use babel-loader syntax compiler ES6

  1. Learn babel

Currently, ES6 (ES2015) This syntax has been very large-scale applications, it has a more compact, more powerful features, the actual project is likely to be adopted ES6 use grammar module, but the browser syntax support for ES6 not perfect. For compatibility, you need to use conversion tool to convert ES5 ES6 grammar grammar, babel is the most commonly used tool

 Change

babel conversion syntax required dependencies:

babel-loader: syntax responsible for transforming es6

babel-core: babel core package

babel-preset-env: transcoding rules tell what kind of file handling using the babel

 

2. Installation depends

npm install babel-loader @babel/core @babel/preset-env --save-dev

 

Configuration config file

 

The exclude not in the specified directory to find the relevant documents

 

4. The new root conversion rule configuration file .babelrc

 

 

 

5. Another configuration rules

 

 

 

Guess you like

Origin www.cnblogs.com/lanlanJser/p/11894044.html