Open bhishp opened 4 years ago
Currently dotenv-expand
is not supported and probably will never be supported. But the idea of expanding existing env vars is a really cool idea. I will look into implementing that. If you would like to throw together a PR to get this feature implemented sooner, feel free to do so 😄
@bhishp I had the same problem and I solved it by using dotenv-cli, which supports dotenv-expand.
You can use it as follows in you package.json:
"start": "dotenv -e .env.staging npm run develop",
This is different from the existing --expand-envs
correct? You have to send the vars in on the CLI or the env variable needs to already exist at run time iiuc?
It would be great to have REACT_APP_APP_VERSION=${npm_package_version}
expand. If dotenv-cli can do it, we should be able to add the feature. Has the pr started for this?
Right now I am using an .env-cmdrc.json
file with a .env
file just for the version expansion. It's not ideal.
I had a play - for simple expansions only, this should work: https://github.com/toddbluhm/env-cmd/pull/253
Is dotenv-expand supported? (https://github.com/motdotla/dotenv-expand)
I think not because I have attempted to add this to the env files but it doesn't work.
REACT_APP_APP_VERSION=${npm_package_version}
(as per CRA docs:) https://create-react-app.dev/docs/adding-custom-environment-variables/#expanding-environment-variables-in-env
Happy to raise a PR to add support if someone could point me in the right direction...