Summary of common specifications of npm scripts
With the increasing use of npm scripts, it is necessary to standardize the use of the word npm run.
definition
I define the following form:
npm run <action>:<scope>:<target>
action: refers to the action, usually expressed as a verb, used to express my intention, which means what I want to do
Scope: refers to the scope under the current action, generally a noun, used to constrain the scope of the action, meaning what do I do in a certain environment
target: Refers to the specific goal, the goal you want to achieve, this is a noun, in this case it is very direct.
example
This may be a bit abstract, but here are a few examples:
npm run start
npm run start:dev
These two commands can be seen, what are they doing, one is production operation, the other is development operation
npm run build
npm run build:html
This is the command to pack the file
npm run lint && npm run test && npm run build && npm run publish
This is the order to execute the command
npm run lint:fe:js & npm run lint:fe:css
This is to execute the command in parallel
illustrate
- It should be noted that if there are too many commands, it is recommended to create a new folder scripts to write commands.
- The general production environment does not need to be marked
- Simplification of workloads that can be used with npm-run-all
Supplementary suggested words
Here are some commonly used words for reference:
action
- lint
- watch
- clean
- build
- start
- test
- publish
scope
- dev
- js
- html
target
- index
- gulp
- jake