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

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

6 回复

参考koahub-cli

来自 KoaHubjs

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

然后 npm run watch-compile

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

来自 KoaHubjs

官方文档 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

回到顶部