How can I run a build for only one environment?

197 Views Asked by At

I am working on a react project, I have several environments, when I run a build for one environment e.g npm run build-sit, the JavaScript files in the build folder contain information about other environments. How do I make sure that the JavaScript files in that build folder only contain information about the environment I am building for.

Here is my scripts in package.json

"scripts": {
  "start": "set REACT_APP_ENV=dev && react-scripts start",
  "build": "react-scripts build",
  "build-test": "set REACT_APP_ENV=test && react-scripts build",
  "build-sit": "set REACT_APP_ENV=sit && react-scripts build",
  "build-staging": "set REACT_APP_ENV=staging && react-scripts build",
  "build-production": "set REACT_APP_ENV=production && react-scripts build",
  "build-company1-uat": "set REACT_APP_ENV=company1Uat && react-scripts build",
  "build-company2-uat": "set REACT_APP_ENV=company2Uat && react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject"  
}

I have a constants.ts file where I set the urls for the different environments

0

There are 0 best solutions below