NPM Scripts -- onchange parallelshell
- Watch for changes to the styles.scss file and automatically compile it to the css file.
- Run multiple NPM scripts in parallel using parallelshell NPM module.
Watching for Changes and Parallelshell
- First, we install two NPM packages onchange and parallelshell as follows:
npm install --save-dev onchange@3.3.0 parallelshell@3.0.2
- Then, add the following two script items to package.json if you are doing the exercise on a MacOS computer or a Linux computer:
"watch:scss": "onchange \"css/*.scss\" -- npm run scss",
"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""
NPM Scripts Part 1
Objectives and Outcomes
In this exercise, you will learn to set up NPM scripts by modifying the package.json file. At the end of this exercise, you will be able to:
- Watch for changes to the styles.scss file and automatically compile it to the css file.
- Run multiple NPM scripts in parallel using parallelshell NPM module.
Moving JS to Script file
- Create a folder named js and in that folder create a file named scripts.js.
- Open index.html and from this file cut out all the JQuery script that we added to it and move the code to the scripts.jsfile that we created above.
- Then, update the index.html file to include the scripts.js file by adding the following line:
- Add the same line to the scripts block in aboutus.html and contactus.html:
Watching for Changes and Parallelshell
- First, we install two NPM packages onchange and parallelshell as follows:
- Then, add the following two script items to package.json if you are doing the exercise on a MacOS computer or a Linux computer:
- NOTE: If you are doing the exercise on a Windows computer, please use the following two script items instead of the above:
- You will also update the start script as follows:
- Then, type the following at the prompt to start watching for changes to the SCSS file, compile it to CSS, and run the server:
NPM Scripts -- onchange parallelshell的更多相关文章
- NPM Scripts 2 -- rimraf copyfiles imagemin usemin htmlmin uglifyjs
NPM Scripts Part 2 Objectives and Outcomes In this exercise you will learn to build a distribution f ...
- [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 ...
- npm Scripts使用教程【译】
Why npm Scripts? 原文发表于 2016.2.12,原文地址: https://css-tricks.com/why-npm-scripts/ 以下是访客Damon Bauer发布的一篇 ...
- npm scripts 助力前端开发,实时刷新浏览器
用browser-sync或者lite-server来监控文件的改变,当文件改变时,就自动刷新浏览器. 用node-sass来实时编译scss文件. 用parallelshell来异步执行npm sc ...
- npm scripts + webpack 实践经验(React、Nodejs)
最近用Webpack+npm scripts+Mongodb+Nodejs+React写了个后台项目,在用Webpack构建过程中遇到了许多坑,就写出来分享一下. 构建工具五花八门,想当年刚学会Gru ...
- [NPM] Pull out npm scripts into another file with p-s
A technique you might use once you start having lots of npm scripts is to use a node package that al ...
- [NPM] Make npm scripts cross-environment friendly
Unfortunately not all shell commands work across various environments. Two main techniques to suppor ...
- windows下npm scripts不能执行的问题
最近在学webpack为了方便把运行脚本写入package.json文件中,如下: "scripts": { "start": "webpack-de ...
- 5.npm scripts 使用指南
简单介绍 scripts里面的 "start": "node app" npm run start 相当于 node app { "name" ...
随机推荐
- squee_spoon and his Cube VI---郑大校赛(求最长子串)
市面上最常见的魔方,是三阶魔方,英文名为Rubik's Cube,以魔方的发明者鲁比克教授的名字命名.另外,二阶魔方叫Pocket Cube,它只有2*2*2个角块,通常也就比较小:四阶魔方叫Reve ...
- 确定比赛名次---hdu1285(拓扑排序)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1285 拓扑序就是求一个序列 数 a 出现在数 b 前面,最终输出满足条件的序列即可: 过程就是每次选取 ...
- The Highest Mark---hdu5501(问题转化 01背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5501 二维数组: #include<stdio.h> #include<iostre ...
- python 通过文件路径获取文件hash值
import hashlib import os,sys def CalcSha1(filepath): with open(filepath,'rb') as f: sha1obj = hashli ...
- 如何用Qt Creator输出helloworld
0 引言:相比于MFC只要直接在VS上搭建,Qt的配置就相对复杂了,Qt新手上路,老司机绕道,记录下配置Qt的整个过程,直到最终用C++输出“hello world”. 搭建环境:Win10 + qt ...
- 对比python的进程和线程:多线程是假的
进程,是系统进行资源分配最小单位(拥有独立的内存单元).(python中多进程是真的) 线程,是操作系统最小的执行单位(共享内存资源),比进程还小.(python中多线程是假的,因为cpython解释 ...
- 004-Shell 基本运算符、算术运算符、关系运算符、布尔运算符、辑运算符、字符串运算符、文件测试运算符
一.概述 Shell 和其他编程语言一样,支持多种运算符,包括: 算数运算符 关系运算符 布尔运算符 字符串运算符 文件测试运算符 二.算术运算符 原生bash不支持简单的数学运算,但是可以通过其他命 ...
- 创建正真的Java不可变类
如果需要设计一个不可变类,尤其要注意其引用类型Field,如果其引用类型Field的类是可变的,就必须采取必要的措施来保护该Field所引用的对象不会被修改,这样才能创建真正的不可变类. class ...
- Spring框架第五篇之Spring与AOP
一.AOP概述 AOP(Aspect Orient Programming),面向切面编程,是面向对象编程OOP的一种补充.面向对象编程是从静态角度考虑程序的结构,而面向切面编程是从动态角度考虑程序运 ...
- docker——安装
Docker划分为CE和EE.CE即社区版(免费,支持后期三个月),EE即企业版,强调安全,付费使用. #安装依赖包 yum install -y yum-utils device-mapper-pe ...