简体   繁体   中英

Is there a way to group dependencies in package.json?

I have a package.json

"dependencies": {
    "@babel/core": "7.2.2",
    "@babel/preset-env": "7.3.1",
    "@babel/register": "7.0.0",
    "babel-loader": "8.0.5",
    "browser-sync": "^2.26.0",
    "@hot-loader/react-dom": "^16.8.6",
    "react": "^16.10.1",
    "react-dom": "^16.10.1",
    "react-hot-loader": "^4.12.13",
    "webpack": "^4.41.0",
    "glob": "^7.1.6",
    "args": "^5.0.1",
    "webpack-dev-middleware": "^3.7.2",
    "webpack-hot-middleware": "^2.25.0"
  },

I have two build processes:

Build A - standard app.

git clone <myrepo.git>
npm install
npm run build-app
deploy

Build B - static files

git clone <myrepo.git>
npm install glob args // I want to read this from package.json
npm run build-static
deploy-static

What I would like is to group dependencies into two groups.

The reason is installing all the dependencies takes about ~2mins. For second build task, I only need 2-3 packages which takes less than 10 seconds. Currently, I have npm install glob args hardcoded in my build program. I want to read it from the same package.json.


I cannot use dependencies vs dependencies because I have some dependencies used just for development and use the flag npm install --production to install only the required dependencies (without devDependencies).

You can surely group them; there are two types of dependencies, one's dev and the other one is production. Here's a reference: https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file

If you want to create more than two, check this package out: https://www.npmjs.com/package/group-dependencies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM