@Tean
2017-11-19T14:25:09.000000Z
字数 692
阅读 661
编译工具
npm install --save-dev babel-cli babel-preset-env
创建文件
.babelrc文件:
{"presets": ["env"]}
package.json中配置
"scripts": {"build": "babel index.js --out-file ./lib/index.js"}# --out-file 可简写为 -o
./node_modules/.bin/babel index.js -o ./lib/index.js
# --out-file 或 -o 输出编辑结果到单个文件babel ./script.js -o ./script-com.js# --watch 或 -w 修改文件后编译文件(监听)babel ./script.js -o ./script-com.js -w# --source-maps 或 -s 生成source-mapbabel ./script.js -o ./script-com.js -s# --source-map inline 生成内联的source-map(不会单独生成文件)babel ./script.js -o ./script-com.js -s inline# --out-dir 或 -d 编译整个目录到目标目录babel ./src -d ./lib# 编译整个文件夹到单个文件中babel ./src -o ./lib/all.js# --ignore 忽略文件babel ./src -d ./lib --ignore jquery.min.jsbabel ./src -o ./all.js --ignore jquery.min.js