On windows, I'm developing a white label app and trying to use env variables to make code specific builds. I'm using react-native-config
and I followed their setup on GitHub, but for some reason SET ENVFILE=.env.myenvironment
doesn't do anything for me, even with a defined map in build-gradle
like this:
project.ext.envConfigFiles = [
debug: ".env",
release: ".env",
anothercustombuild: ".env.custombuild",
]
Any ideas?
I was using vscode integrated terminal to pass the react-native-config
command to tell RN which .env file to look at, and it wasnt working at all..
I started using powershell for windows and tryed the correct command for it. And it work wonders. e.g.
$env:ENVFILE=".env.mycustomenvironment"; react-native run-android
. It should work the same for react-native run-ios
as well as for release builds.
Keep in mind that as of right now (08/20/2019), react-native-config
isnt working properly with product flavors in RN 0.60+ when it comes to exposing the .env vars to your .JS files, if you are looking for a workaround for that, take a look at this post but tl;dr is to use react-native-config
with react-native-build-config
.