首页 > 其他 > 详细

[NPM] Run npm scripts when files change with onchange

时间:2017-02-07 20:22:07      阅读:113      评论:0      收藏:0      [点我收藏+]

In this lesson we will look at how we can setup our npm scripts to execute when the file system has changed. Some common examples of this are automatically linting your code, running unit tests, or using a pre-processor for your CSS.

 

Install:

npm i -D onchange

 

For example, you want to watch all the js file and scss file, to check the tests and lints.

For lints:

    "lint": "npm-run-all lint:**",
    "lint:js": "eslint --cache --fix ./",
    "lint:css": "stylelint ‘**/*.scss‘ --syntax scss",
    "lint:css:fix": "stylefmt -R src/",
    "watch:lint": "onchange ‘src/**/*.js‘ ‘src/**/*.scss‘ -- npm run lint",

And for tests:

    "watch": "npm-run-all --parallel watch:*",
    "watch:test": "npm t -- --watch",
    "watch:lint": "onchange ‘src/**/*.js‘ ‘src/**/*.scss‘ -- npm run lint",

 

[NPM] Run npm scripts when files change with onchange

原文:http://www.cnblogs.com/Answer1215/p/6375519.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!