Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Multi-env and caching #115

Closed
Esxiel opened this issue Feb 10, 2021 · 5 comments
Closed

Question: Multi-env and caching #115

Esxiel opened this issue Feb 10, 2021 · 5 comments
Labels
wontfix This will not be worked on

Comments

@Esxiel
Copy link

Esxiel commented Feb 10, 2021

First of all, thanks for the library, the multi-env feature it provides makes it much better.

I have a question about the multi-env and the caching...
I understand that the .env.production / .env.development (defined environment variables) overwrite the general .env

The base set of variables will be .env and the environment-specific variables will overwrite them.
as stated in the readme... but does this work without resetting one's cache?

e.g. I have a .env and a .env.production. I yarn start to run a bundler for fixing a bug on a debug build. I then stop the bundler and re- yarn start before proceeding to "Archive" using XCode to distribute my app. Will the Archive app use values from the .env or .env.production?

I've had a problem with the .env variables and I'm just trying to figure out if it was the caching or something else.

@goatandsheep
Copy link
Owner

What happens if you do yarn start --reset-cache?

@Esxiel
Copy link
Author

Esxiel commented Feb 19, 2021

Huh, I tried it again today and it seems like it's not even reading my .env.production even after I yarn start --reset-cache , but I swear it worked at least once before...

To be clear, what I did was

  1. yarn start --reset-cache with a .env pointing to endpoint A, and build for debug
  2. yarn start --reset-cache, and build for release/production (with a .env.production pointing to endpoint B)
  3. the release build, on the simulator, shows that its pointing to endpoint A

What I expect,
on step 3, the release build should point to endpoint B

@Esxiel
Copy link
Author

Esxiel commented Feb 19, 2021

Am I misunderstanding the priority?
Like is it actually
(Release) .env > .env.production
(Debug) .env > .env.development

rather than
(Release) .env.production
(Debug) .env.development

or am I misunderstanding that, at least as far as I remember, .env.production and .env.development is done automatically by the metro bundler and requires no extra setup (like specifying an environment variable on yarn start e.g. "APP_ENV=staging npx react-native start") ?

@goatandsheep
Copy link
Owner

In general you shouldn't need APP_ENV but it's there in case you need it. By default the library uses your babel environment which as you said release / production , debug / development.

I think you meant
.env < .env.development
And
.env < .env.production

However if the babel env is not reporting properly, it will default to .env.development. If you can't figure out why your production environment is reporting development, easiest thing is to just use app_env=production

@stale
Copy link

stale bot commented Apr 20, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Apr 20, 2021
@stale stale bot closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants