onchange 可以和 gulp、grunt 的 watch 一样强大。
npm i onchange -D
"scripts": {
"watch": "onchange \"**/*.html\" \"**/*.css\" \"**/*.js\" -- npm test"
}
npm i browser-sync-D
"scripts": {
"test": "browser-sync start --server --files \"**/*.html, **/*.css, **/*.js\""
}
src
├── images
│ └── schedule.png
├── index.html
├── scripts
│ └── main.js
└── styles
└── main.css
功能要求
- 压缩图片;
- 编译 less、压缩 css;
- 编译、压缩 js;
- 给图片加版本号并替换 js、css 中的引用;
- 给 js、css 加版本号并替换 html 中的引用;
https://github.com/wangshijun/automated-workflow-with-npm-script