I am using dotenv with create-react-app. I have three different .env files in my root directory.
I have
.env
.env.develop
.env.stage
I want the variables in these file to map as described below
.env -> production site
.env.develop -> local development
.env.stage -> stage site
I am guessing that I have to make some changes to the scripts object in the package.json file but I am not sure of what to exactly do.
My current package.json is as follows
{
"name": "web_app",
"version": "0.1.0",
"private": true,
"homepage": "",
"devDependencies": {... },
"dependencies": {... },
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
So I would like to know how to tell react to use the correct .env file for each environment.
Thanks in advance to anyone who can help