Use Scripty release npm-script (Windows)

What is?

Use npm-scripts has become a common method of maintaining Node.js modules required to develop a variety of building tasks. Because it is very simple!

Just add a small script package.json, and then use npm run name: of: script run

When too npm script or becomes complicated, package.json will lead to confusion, poor readability.

We can use scripty be npm script to release a separate file, so that the complexity of the compartment to the inside of a separate module, so that the overall code look clearer.

Install

npm install scripty --save-dev

Usage

For example: Our package.json changed to this format

"scripts": {
  "client:dev": "scripty",
  "client:prod": "scripty",
  "client:server": "scripty",
}
  1. Created under the project directory scripts directory, create a directory inside the client, create dev.sh in the client, server.sh, prod.sh script

For example: dev.sh   :   WebPACK --mode Development

     2. Run "npm run client: dev" will automatically execute the script dev.sh that the implementation of "webpack --mode development"

Windows:

However, sh file can not be run directly from the windows! Therefore, in accordance with the above manner using scripty may be error in windows

spawn:UNKOWN

So, create scripts-win directory in the Windows environment, change the .sh file .bat file, remaining above


npm-scripty address

Published 88 original articles · won praise 16 · views 40000 +

Guess you like

Origin blog.csdn.net/qq_36157085/article/details/97118076