Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ set REACT_APP_COLOR=navy&& set REACT_APP_MAIN_TEXT=Navy Background&& npx react-i

`.env` files are supported. `react-inject-env` will automatically detect environment variables in your `.env` file located in your root folder.

If you want to customize the `.env` file name, you can define the file name in environment variable `REACT_APP_DOTENV_CONFIG_PATH`.

Note: Environment variables passed in through the command line will take precedence over `.env` variables.

## Typescript
Expand Down
3 changes: 2 additions & 1 deletion src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export function retrieveReactEnvCfg(): Record<string, string> {

export function retrieveDotEnvCfg(): Record<string, string> {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const env = require('dotenv').config().parsed ?? {}
const path = process.env.REACT_APP_DOTENV_CONFIG_PATH ?? '.env';
const env = require('dotenv').config({path: path}).parsed ?? {}

const keys = Object.keys(env)
const reactKeys = keys.filter(key => {
Expand Down