[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 ...
随机推荐
- zookeeper 配置文件说明(zoo.cfg)
clientPort # 客户端连接server的port,即对外服务port,一般设置为2181. dataDir # 存储快照文件snapshot的文件夹. 默认情况下.事 ...
- HTML的SEO(搜索引擎优化)标准
HTML的SEO(搜索引擎优化)标准 一.总结 这个做seo的时候要多看,做网站优化的时候 1. SEO(搜索引擎优化):通过总结搜索引擎的排名规律,对网站进行合理优化,使你的网站在百度和Google ...
- 解决浏览器不兼容websocket
本例使用tomcat 7.0的websocket做为例子. 1.新建web project.2.找到tomcat 7.0 lib 下的 catalina.jar,tomcat-coyote.jar添加 ...
- HTML基础第九讲---表单
转自:https://i.cnblogs.com/posts?categoryid=1121494 最基本的留言版应该大家都用过吧!没错这就是一个表单运用很好的例子.表单提供了一个管道让读者发表心声, ...
- 108.sqllite3(C语言数据库库)详解
//创建数据库,插入表,生效 //创建数据库,插入表,生效 void create_database() { //数据库指针 sqlite3 *db=; //打开数据数据库,初始化指针 int res ...
- 104.tcp多线程读写实现群聊
客户端: #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #include <w ...
- vb.net structure 定义静态数组
Const RAS95_MaxEntryName = 256 Const RAS95_MaxDeviceName = 128 Const RAS_MaxDeviceType = 16 Structur ...
- 【Codeforces Round #429 (Div. 1) B】Leha and another game about graph
[链接]点击打开链接 [题意] 给出一个连通图,并给每个点赋一个d值0或1或-1,要求选出一个边的集合,使得所有的点i要么d[i] == -1,要么 dgree[i] % 2 == d[i],dgr ...
- JS学习笔记 - 运动 - 淘宝轮播图
<script> window.onload=function () { var oDiv=document.getElementById('play'); var aBtn=oDiv.g ...
- Loadrunner--关联详解
当录制脚本时,VuGen会拦截client端(浏览器)与server端(网站服务器)之间的对话,并且通通记录下来,产生脚本.在VuGen的Recording Log中,您可以找到浏览器与服务器之间所有 ...