facebook/metro

[Feature Request] - Public env variables loading customization option

ernestostifano opened this issue · 0 comments

Do you want to request a feature or report a bug?

Request a feature

What is the current behavior?

Currently, environment variables are loaded according to the docs (Environment variables in Expo), which is working just fine, but it cannot be customized.

What is the expected behavior?

It would be nice to have the possibility to customize which env variables get loaded into the app, without needing to use the EXPO_PUBLIC_ prefix.

Our use case is that we have a monorepo with multiple projects (FE Web, FE Mobile, BE Node, etc.) and there is a centralized approach to environment variables handling. So, we have managed to apply out custom approach to all projects, but not the EXPO ones.

As an example, Storybook supports the following approach:

const config = {
  /*
   * 👇 The `config` argument contains all the other existing environment variables.
   * Either configured in an `.env` file or configured on the command line.
   */
  env: (config) => ({
    ...config,
    EXAMPLE_VAR: 'A custom environment variable'
  })
};

Our final goal is not only to achieve consistency in environment variables naming across projects, but some variables can only be calculated during the build/start process, depending on the context.

Thanks for your time!