检测文件变化然后执行 npm scripts
// ./watch.js
const watch = require('nswatch')
watch('src/*.js', ['build'])
同样可以在 package.json
里配置:
{
"watch": {
"./src/*.js": ["build"],
"./src/*.css": "compile!minify"
}
}
然后在终端里执行:
$ nswatch
当然也可以直接通过参数运行:
# in parallel
$ nswatch "src/*.js" --script foo --script bar
# in sequence
$ nswatch "src/*.js" --script "foo!bar"