babel-cli命令行
安装:"@babel/cli": "^7.7.7", "@babel/core": "^7.7.7",
1. -d,--out-dir [out] 指定输入目录,编译输出到指定目录
npx babel src -d lib
2. --source-maps [true,false,inline,both] 增加source map文件
npx babel src -d lib --source-maps
3. -o,--out-file [out] 指定输入文件或目录,合并编译输出到一个新文件
npx babel index.js -o compile.index.js
4. -w,--watch 监听文件修改并执行编译
npx babel src -d lib --source-maps --watch
5. --ignore 忽略指定正则文件
npx babel src -d lib --source-maps --ignore "node_modules/**/*.js"
6. --copy-files 拷贝文件(可通过其方式实现)
npx babel src -d lib --copy--files
7. 通过管道输入文件
npx babel src -o compiled.js<index.js -f index.js --source-maps
8. --plugins 使用插件
npx babel src -d lib --plugins=@babel/plugin-transform-arrow-functions
9. --presets 预设
npx babel src -d lib --presets=@babel/preset-env
10. --no-babelrc 忽略.babelrc,并通过命令行参数执行构建流程
npx babel --no-babelrc src -d lib --plugins=@babel/plugin-transform-arrow-functions
11. 自定义配置文件路径
npx babel --config-file /path/to/my/babel.config.json --out-dir dist ./src