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

Feature request: Export function for programmatically loading .env files #253

Closed
hrastnik opened this issue Nov 22, 2021 · 5 comments
Closed
Assignees

Comments

@hrastnik
Copy link

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?

@github-actions
Copy link

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

@goatandsheep
Copy link
Owner

Try using dotenv-flow

@stale
Copy link

stale bot commented Feb 3, 2022

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 Feb 3, 2022
@goatandsheep
Copy link
Owner

or try using process.env?

@stale stale bot removed the wontfix This will not be worked on label Feb 7, 2022
@haelsisy
Copy link

haelsisy commented Apr 4, 2024

How did you manage to do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants