在node中用 babel-cli 转译 es6时,怎样可以监测文件变化 就自动执行 package.json 中的 scripts 命令啊???
 发布于 8 年前  作者 xialexiatian  4586 次预览  最后一次回复是 8 年前  来自 问答 

在node中用 babel-cli 转译 es6时,怎样可以监测文件变化 就自动执行 package.json 中的 scripts 命令啊??? 如何才能避免 不需要 每改动一次代码,就得 手动输入一次 npm run es6 命令来执行 转译啊??? babel.png

6 回复
einsqing

参考koahub-cli

来自 KoaHubjs

richenlin

package.json内添加scripts命令 “watch-compile”: “babel src -d App -D --watch”,

然后 npm run watch-compile

einsqing

@dlutwuwei 跑内存了,太卡,速度慢。

来自 KoaHubjs

BoyInWindows

官方文档 cli-babel To compile a file every time that you change it, use the --watch or -w option: babel script.js --watch --out-file script-compiled.js