[NPM] Create a bash script to replace a complex npm script
In this lesson we will look at pulling out complex npm scripts into their own external bash scripts. This ends up simplifying your package.json file and abstracts the complexity into another file.
From:
"pretest": "npm run lint",
"test": "BABEL_ENV=test mocha spec/ --require babel-register",
To:
1. Create "scripts" folder and "test.sh" file:
#!/usr/bin/env bash npm run lint
BABEL_ENV=test mocha spec/ --require babel-register
Then update package.json
"test": "./scripts/test.sh",
and remove "pretest" script.
2. Add premisson to the bash files:
cd scripts
chmod -R . // change premission for all files in script folder
3. Can add some messages:
From :
"build": "npm-run-all build:*",
"prebuild": "rm -rf public/$npm_package_version",
"build:html": "pug --obj data.json src/index.pug --out public/$npm_package_version/",
"build:css": "node-sass src/index.scss | postcss -c .postcssrc.json | cssmin > public/$npm_package_version/index.min.css",
"build:js": "mustache data.json src/index.mustache.js | uglifyjs > public/$npm_package_version/index.min.js",
TO:
"build": "./scripts/build.sh",
#!/usr/bin/env bash echo "Building..."
rm -rf public/$npm_package_version
pug --obj data.json src/index.pug --out public/$npm_package_version/
node-sass src/index.scss | postcss -c .postcssrc.json | cssmin > public/$npm_package_version/index.min.css
mustache data.json src/index.mustache.js | uglifyjs > public/$npm_package_version/index.min.js
echo "Finished building."
[NPM] Create a bash script to replace a complex npm script的更多相关文章
- [NPM] Create a node script to replace a complex npm script
In this lesson we will look at pulling out complex npm script logic into an external JavaScript file ...
- npm不能安装任何包,报错:npm WARN onload-script failed to require onload script npm-autoinit/autoinit及解决方法
想要利用Hexo搭建一个博客,但是安装时npm一直报错,不仅仅是Hexo包,连别的其他包也不行,会提示下面的一堆错误 npm WARN onload-script failed to require ...
- npm ERR! Failed at the gff@1.0.0 start script.
code ELIFECYCLE npm ERR! errno 1 npm ERR! gff@1.0.0 start: `node build/dev-server.js` npm ERR! Exit ...
- npm缺少css-loader,/style-compiler,stylus-loader问题,npm没有权限无法全局更新问题【已解决】
ERROR in ./node_modules/css-loader!./node_modules/vue-loader/lib/style-compiler?{"vue":tru ...
- <script src="../build/browser.min.js"></script> 是用来里面babel工具把ES6的语法转成ES5
<!DOCTYPE html> <html> <head> <script src="../build/react.js">< ...
- [NPM] Create a new project using the npm init <initializer> command
Historically, the npm init command was solely use to create a new package.json file. However, as of ...
- How do I create an IIS application and application pool using InnoSetup script
Create an IIS application. Create a new IIS application pool and set it's .NET version to 4. Set the ...
- vue-cli3.x npm create projectName 报错: Unexpected end of JSON input while parsing near......
npm 版本与node版本还有webpack版本之间的问题 清理缓存,“ npm cache clean --force " 一切OK
- npm ERR! Failed at the node-sass@4.13.0 postinstall script
node-sass 的数据源没设置 npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass 重新 npm in ...
随机推荐
- JSP页面开发规范案例
添加 <%@ page language="java" contentType="text/html; charset=utf-8" pageEncodi ...
- LinearLayout-layout_gravity 属性没有效果分析
今天在一个布局文件中,遇到了一个问题,先看代码 <LinearLayout android:layout_width="match_parent" android:layou ...
- <%%>创建内联代码块(表达式)
其实<%%>很早之前就见过了,只是会用一点功能,其它的不甚了解.今天偶尔见到了它的庐山真面目,现在共享给大家. 语法 代码块呈现(<%%>)定义了当呈现页时执行的内联代码或内联 ...
- 原生js大总结十一
101.请简述prototype.__proto__ constructor三者的关系 1.prototype: 每一个函数都有一个prototype这个属性,而这个属性指向一个对象,这个 ...
- 你真得懂Javascript中的==等于运算符吗?
var i = 2; Number.prototype.valueOf = function() { return i++; }; var a = new Number( 42 ); if (a == ...
- [Angular] Using the Argon 2 Hashing Function In Our Sign Up Backend Service
Which hash algorithom to choose for new application: https://www.owasp.org/index.php/Password_Storag ...
- Python模块学习笔记— —random
Python中的random模块用于生成随机数. random.random 函数原型 random.random() 生成一个范围在[0,1)的随机浮点数. import random print ...
- [Angular2 Router] Redirects and Path Matching - Avoid Common Routing Pitfall
In this tutorial we are going to learn how we can can configure redirects in the angular 2 router co ...
- 写PPT的先扬后抑的思路
近期给一个客户做IT战略规划. 基本结束了,客户要求写点有高度的东西.我想也是,尽管眼下的PPT也触及到战略和行业的问题,可是没有总结出来.于是就挖空心思,琢磨了三天.写了4页PPT.改动了几遍.还算 ...
- Android 中AIDL的使用与理解
AIDL的使用: 最常见的aidl的使用就是Service的跨进程通信了,那么我们就写一个Activity和Service的跨进程通信吧. 首先,我们就在AS里面新建一个aidl文件(ps:现在AS建 ...