Open charlesjohannisen opened 7 years ago
@charlesjohannisen I’ve forked this package to allow for more options and fix issues like this one.
https://github.com/tusbar/babel-plugin-dotenv-import
It’ll let you do that with { allowUndefined: true }
.
@zetachang can we have this feature?
It would be really useful to have this feature
@zetachang any reason not to merge this PR? This is a must have
Can we please merge this feature?
bump. This feature is critical for use with github actions.
I think the repo is pretty much abandoned by this time :(
There's a new repo and package babel-plugin-dotenv-import. Please reopen in the new repo
Or just write your env variables to a environment.js file using a script that runs right before the bundler and import that file as a module anywhere in the application.
Having a package to do this not only adds an unnecessary dependency but it also messes up the metro bundler cache, meaning you have to use --reset-cache every time you change the environment while running the packager server. Unless you dive deep into metro to write some kind of Middleware, it will assume a module with the same version always exports the same thing and cache it thus using the environment of the first cached version even if you change it. It is a pretty sane and safe assumption by the way, and mandatory if you want any kind of cache of the node_modules folder.
Allows you to
import { MY_VAR, MY_OPT } from 'react-native-dotenv'
even if the var is not defined in the env file or if the env file doesn't exist. Throwing an exception removes the optional nature of an .env file. As mentioned in this issue rather give the dev the option to assign the variable conditionally:myconfig.MY_VAR = MY_VAR || 'default'