zoukankan      html  css  js  c++  java
  • [NPM] Run npm scripts when files change with onchange

    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",
  • 相关阅读:
    Git 基本操作
    Git 基础
    MarkDown教程
    Python常用函数
    Python生成器
    Python列表生成式
    Python迭代
    Python切片
    Python函数
    Python不可变对象
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6375519.html
Copyright © 2011-2022 走看看