Udi Mazor
Udi Mazor

Reputation: 1826

How to run multiple commands in a single package.json line with configuration

I want to run the to build commands (clienr and server) in one npm run commands. So on my package.json scripts section I added this line:

"build-all": "ng build --prod && ng run web-app:server",

The problem occurs when I run this commands: npm run build-all --configuration=qa.europe.

The configuration is loaded when I run each commands separately but not when I run the above commands.

Any ideas?

Upvotes: 1

Views: 3822

Answers (2)

Ankit Kumar Rajpoot
Ankit Kumar Rajpoot

Reputation: 5600

You can try this.

  "scripts": {
    "start:production": "npm install && npm run build && npm run start:prod",
    "start:prod": "cross-env NODE_ENV=production node server",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }

npm run start:production it will run "start:production" & "start:prod" both scripts

Upvotes: 1

Fedor Saenko
Fedor Saenko

Reputation: 138

You can try to use postinstall, it will look as next:

"scripts": {
    "start": "ng run web-app:server",
    "postinstall": "ng build --prod --configuration=qa.europe",
}

So after npm install, the build of your UI starts. And after that will start your server.

Upvotes: 0

Related Questions