score:12

Well, the article is actually right. I had a bug in my code, where I had hard-coded the value rather than relying on process.env.REACT_APP_SOMEVAR

These scripts in package.json work fine:

"start": "REACT_APP_ENV=dev npm run start-env",
"start-env": "sh -ac '. .env.${REACT_APP_ENV}; react-scripts start'",
"start-dev": "REACT_APP_ENV=dev npm run start-env",
"start-qa": "REACT_APP_ENV=qa npm run start-env",
"build": "REACT_APP_ENV=dev npm run build-env",
"build-env": "sh -ac '. .env.${REACT_APP_ENV}; react-scripts build'",
"build-dev": "REACT_APP_ENV=dev npm run build-env",
"build-qa": "REACT_APP_ENV=qa npm run build-env",

Related Query

More Query from same tag