Files
tldr/pages.zh/common/babel.md
2020-11-04 17:12:56 -03:00

33 lines
816 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# babel
> 一款JavaScript的编译器将下一代ES语法转换为兼容语法。
> 更多信息: <https://babeljs.io/>.
- 转编译指定文件到标准输出:
`babel {{路径/到/文件}}`
- 转编译指定文件,输入为特定文件:
`babel {{路径/到/输入文件}} --out-file {{路径/到/输出文件}}`
- 监听文件变动触发转编译:
`babel {{路径/到/输入文件}} --watch`
- 转编译整个目录下的js文件:
`babel {{路径/到/输入文件目录}}`
- 跳过指定目录下指定文件的编译(多文件使用英文逗号“,”分隔):
`babel {{路径/到/输入文件目录}} --ignore {{被忽略文件}}`
- 转编译后,执行压缩:
`babel {{路径/到/输入文件}} --minified`
- 使用预设值:
`babel {{路径/到/输入文件}} --presets {{预设项}}`