Skip to content

Define custom .env files for custom development stages. #3903

@Baldeep

Description

@Baldeep

I think it would be useful to be able to define a custom .env file.

I have three different environments my app will run on: dev, staging, and production. dev and production are covered, but right now it doesn't seem like there's any easy way to have separate environment variables for other stages.

It would be handy if an additional environment variable could be specified to select the custom .env file, and use the default .env files if the additional variable is undefined.

e.g. (in Windows)

start: react-scripts start - uses .env.development
start: "set REACT_APP_ENV=devstaging & react-scripts start" - uses .env.devstaging
build_staging: "set REACT_APP_ENV=staging & react-scripts build" - uses .env.staging
build: "react-scripts build" - uses .env.production

The custom .env file would be overriden by the .local version, just how it works currently with development, production, and test.

I'm not confident enough to make the change myself, but it seems like adding this would require a change in the react-scripts -> config -> jest -> env.js file, where the dotenvFiles variable is set (react-scripts v1.0.11).

Creating this from my comment on Issue 102 A way to define custom environment variables.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions