- Project initialization
npm init
- Install babel in the project
npm install babel-cli --save-dev
- Install related babel plugins
# babel-preset-xxxxxx
npm install babel-preset-es2015 --save-dev
- Rewrite package.json
# src:源目录;lib:目标目录
{
"devDependencies": {
"babel-cli": "^6.0.0"
},
"scripts": {
"build": "babel src -d lib"
},
}
- The configuration file in the root directory. babelrc
# presets:转码规则,plugins:插件
{
"presets": [],
"plugins": []
}
- transcoding
The src transcoded file is under lib
npm run build