I am using create react app to bootstrap my app.
I have added two .env
files .env.development
and .env.production
in the root.
If you want to use multiple environment like .env.development
.env.production
use dotenv-cli package
add .env.development
and .env.production
in project root folder
and your package.json
"scripts": {
"start": "react-app-rewired start",
"build-dev": "dotenv -e .env.development react-app-rewired build",
"build-prod": "dotenv -e .env.production react-app-rewired build",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject"
},
then build according to environment like
npm run-script build-dev