1

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?

3
  • Did you get any errors when running npm run build-all? Commented Oct 15, 2019 at 12:23
  • please add package.json content so we can see the scripts Commented Oct 15, 2019 at 13:30
  • I am not getting any errors but the configuration is not applird Commented Oct 15, 2019 at 22:39

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

But I am changing the configuration per environment. I cant hard code it in the package.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.