I am creating React app with Visual studio 2017 template
I have created .env.qa and .env.staging in root of ClientApp
packages.json
"scripts": {
"start": "rimraf ./build && react-scripts start env-cmd -f .env.qa", // some I may need to call qa config
"build": "react-scripts build", // for production push
"build:staging": "env-cmd .env.staging react-scripts build", // for staging push
"build:qa": "env-cmd .env.qa react-scripts build --env=qa", // for qa push
"test": "cross-env CI=true react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint ./src/"
}
.csproj
`
`
My exception is to override variables on qa and staging
You need to install the dotenv package, and import it as early as possible on your App mount with import dotenv from 'dotenv'
Issue is version "env-cmd": "8.0.2",
when I am updating to latest one its not working other wise working as expected
You should file this at https://github.com/facebook/create-react-app/issues
Most helpful comment
You need to install the
dotenvpackage, and import it as early as possible on your App mount withimport dotenv from 'dotenv'