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的更多相关文章

  1. [NPM] Run npm scripts in parallel

    In this lesson we will look at running several npm scripts in parallel. Sometimes you don’t need scr ...

  2. [NPM] Run npm scripts in series

    After creating several npm script it becomes useful to run multiple scripts back-to-back in series. ...

  3. [NPM] Run npm scripts with git hooks

    In this lesson we will look about how we can integrate with git hooks to help enforce a certain leve ...

  4. [Whole Web] [Node.js] Using npm run to launch local scripts

    npm run allows you to configure scripts inside of your package.json file which can access locally in ...

  5. npm run eject 命令后出现This git repository has untracked files or uncommitted changes错误

    npm run eject 暴露隐藏的文件,不可逆 结果出现下面的问题 This git repository has untracked files or uncommitted changes: ...

  6. 在package.json中配置Script执行npm run tslint报错问题

    今天在学习tslint的时候,按照git clone下angular2-webpack-starter的代码执行npm run lint时,虽然代码进行了检测,但检测完成后npm始终报错, //pac ...

  7. Electron 桌面应用打包(npm run build)简述(windows + mac)

    最近一段时间在用electron+vue做内部项目的一键构建发布系统的桌面应用,现就其中打包流程写个备注,以示记录. Windows环境打包:1.首先贴一下package.json. { " ...

  8. npm link & run npm script

    npm link & run npm script https://blog.csdn.net/juhaotian/article/details/78672390 npm link命令可以将 ...

  9. nuxt.js 初始化 npm run dev 报错

    在初始化 npm install 了基本依赖后: npm run dev 报错: error in ./server/index.js Module build failed: Error: Plug ...

随机推荐

  1. 5.3.7 UserDict对象

    用户自己定义字典类UserDict,它是封装了一个字典类dict.主要使用来拷贝一个字典的数据.而不是共享同一份数据. class collections.UserDict([initialdata] ...

  2. mysql测试spring事务是否生效

    同时对三张表进行插入操作,事务保证完整性.下面进行简单测试: 1. 锁定表 锁定用户表 LOCK TABLES user WRITE; 查看表是否锁定: show ; 显示被锁定的表. 2. 验证在同 ...

  3. 洛谷 P1458 顺序的分数 Ordered Fractions

    P1458 顺序的分数 Ordered Fractions 题目描述 输入一个自然数N,对于一个最简分数a/b(分子和分母互质的分数),满足1<=b<=N,0<=a/b<=1, ...

  4. 推荐一个iOS应用UI界面设计站点

    Patterns是一个分享ios应用UI界面的站点,专注于分享iOS应用UI界面的细节.依照设计元素进行分类,依照iOS经常使用功能对各类UI进行分类展示. 链接:url=http%3A%2F%2Fw ...

  5. amazeui学习笔记--css(常用组件7)--输入框组Input-group

    amazeui学习笔记--css(常用组件7)--输入框组Input-group 一.总结 1.使用:Input group 基于 Form 组件和 Button 组件扩展,依赖这两个组件.在容器上添 ...

  6. 【几何/数学】概念的理解 —— (非)刚体变换((non-)rigid transformation)

    1. 刚体变换与非刚体变换 What is a non-rigid transformation? 刚体变换(rigid transformation)一般分为如下几种: 平移对象,而不改变形状和大小 ...

  7. SpringMVC,采用的是SpringJDBC

    上一次复习搭建了SpringMVC+Mybatis,这次搭建一下SpringMVC,采用的是SpringJDBC,没有采用任何其他的ORM框 架,SpringMVC提供了一整套的WEB框架,所以如果想 ...

  8. springmvc hibernate整合

    今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多 了,Spring-Security的就留在下一篇吧,这篇主 ...

  9. 2、HZK和FreeType的使用

    HZK16汉字库的使用 定义如下: unsigned char str[]="我" 在运行时str被初始化为2个字节长度,内容为“我”的GBK码,为:0xCE(区码),0xD2(位 ...

  10. [AngularFire 2] Joins in Firebase

    Lets see how to query Firebase. First thing, when we do query, 'index' will always help, for both SQ ...