Feature request: Export function for programmatically loading .env files
hrastnik opened this issue · 5 comments
What I'm trying to achieve:
I would like to use environment variables to control whether some babel plugins will be enabled. Namely - I want to include babel-plugin-transform-remove-console
when the env variable DISABLE_LOGGING
is set to true
. This variable is configured in my .env.dev
file.
I'm trying to achieve this by reading the value of the DISABLE_LOGGING
env variable in my babel.config.js
config, but
in order to access the variable through process.env.DISABLE_LOGGING
, I have to first load the react-native-dotenv
babel plugin.
Solution:
It would be nice if react-native-dotenv
exported the config function similar to the dotenv
package which can be used like so require('dotenv').config()
.
I have been able to achieve this effect using this code, but it's undocumented and feels kind of hacky.
const dotenv = require("react-native-dotenv")({});
dotenv.pre();
Is it possible to extract the configuration function and export it separately?
Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/253
Try using dotenv-flow
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.
or try using process.env
?
How did you manage to do it?