zetachang / react-native-dotenv

A Babel preset let you import application configs from .env file (zero runtime dependency)
MIT License
915 stars 68 forks source link

Single import that populates process.env #48

Closed stpch closed 5 years ago

stpch commented 6 years ago

First of all nice idea doing env variables with Babel / JS instead of native modules.

It would be great if a single import 'react-native-dotenv'; populated process.env so that env variables could be accessed the regular process.env.MY_VAR way. Not sure if this is possible with the Babel approach.

Moai- commented 6 years ago

I agree. import * as dotenv from 'react-native-dotenv' results in an error. It would be really nice if we were able to import all, and then iterate through dotenv and assign it to process.env or whatever other global we want to use.

cf-bosung90 commented 6 years ago

This will not work since assigning to process.env is done at runtime but you cannot control which code will be ran first, unless process.env is purely accessed at a later in time.