kHRISl33t / runtime-env-cra

Runtime environment handler for create-react-apps
MIT License
49 stars 23 forks source link

Suggestion: Add ability to merge .env file values with process.env values #24

Open RomaRudyak opened 1 year ago

RomaRudyak commented 1 year ago

Hi runtime-env-cra team, Thank you for the tool it helps with a build-once-deploy-everywhere approach.

I would like to suggest merging .env file values with process.env. The flow:

  1. load the .env file
  2. the override values from process.env

This will help to have default configs and dynamically override only few of them.

Thanks

kHRISl33t commented 1 year ago

Hey!

Let's say I have a .env.example like this:

FOO=BAR
API_URL=https://something.api.com/

And where the application runs, only API_URL is set in the environment variables, and FOO should be set dynamically from the .env.example because it's not set as an environment variable.

I can see this working with a CLI flag. Something like --dynamic-merge? What do you think?