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
how multi env works? #74
Comments
I need to add this to the readme. Sorry! Basically this is based on the Babel environments: So sorry, neither dev nor prod will work, but test will! The reason why we're not checking the React Native variable is because we don't have to. This value is inserted at build time. |
Not quite understand, but just waiting for your docs. Thanks so much. |
@lkspc I've expanded on the docs. Let me know if that helps |
Hello @goatandsheep, It is still not clear to me how to use it. What exactly I need to do with Babel? I've created two files
and also link above is broken |
@arys777 sorry about the link. this is the link. Regarding which environment you choose, this is from your CLI commands. By default, the CLI commands have
|
Now I see, thanks so much for the help! |
@goatandsheep |
Well the CLI is really an easy way to setup the XCode configuration. Remember that in XCode
Read more about how to set that here: https://shockoe.com/ideas/development/how-to-setup-configurations-and-schemes-in-xcode/ |
Could I have a |
It seems that I have found the solution in the above article, thank you very much for your help! |
I've updated the docs https://github.com/goatandsheep/react-native-dotenv/wiki/Multi-env-troubleshooting |
@lkspc did you manage to successfully have a |
@francisleigh you won't be able to set the node env environment variable in that way. You'll have to do you through your cli command. Check the troubleshooting guide https://github.com/goatandsheep/react-native-dotenv/wiki/Multi-env-troubleshooting |
@goatandsheep Thanks for your reply. Forgive me but I'm looking at your link which I have previously looked at and am still struggling to get the "ios:staging": "NODE_ENV=test && BABEL_ENV=test && react-native run-ios", Am I completely missing the mark here? It would be great to have an example of setting up a .env.test or if anyone has managed to successfully setup a |
@francisleigh I am thinking about this. I think you're right that within XCode it is not properly acknowledging |
I'm happy it's working for you but I'd like to leave a disclaimer to anyone reading that this is an undocumented usage of babel env to use a non standard babel env such as "staging". It could be removed over time and is probably defaulting to development type rules which could be ok. There are 3 standard babel env versions: development, production, and test. https://babeljs.io/docs/en/config-files#apienv What's cool though is that you can use custom env types if the env name begins with "test-". This is supported so i encourage it and will probably add it to the docs. |
I see, didn't realize that those were the only supported babel environments. To use the "test-" environments would I need to change my .env file to be ".env.test-staging" ? |
@pedromcunha to be honest, I don't know but that is my best guess! Let me know how it goes. |
I'm sorry but I really dont know how it works. If there are two files
.env.dev
and.env.prod
,how does dotenv choose the right one?Does it need environment variables from command line like
yarn start NODE_ENV=pro
? But how to do if I build the project in xcode where I cannot use command line variables?NOTE:
.env.dev
and.env.prod
are both used in Release version, not in Debug. They are different from React Native global variable__DEV__
.The text was updated successfully, but these errors were encountered: