Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dotenv-flow-webpack): add options.pattern for customizing .env* files' naming convention #30

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

kerimdzhanov
Copy link
Owner

Summary

This PR introduces a new configuration option pattern. It allows users to define a custom naming convention for .env* files that dotenv-flow-webpack will read.

The default value for the pattern option is ".env[.node_env][.local]" which is fully backward-compatible with the current dotenv-flow's naming convention.

Description

options.pattern allows you to change the default .env* files' naming convention if you want to have a specific file naming structure for maintaining your environment variables' files.

Default Value

The default value ".env[.node_env][.local]" makes dotenv-flow-webpack look up and load the following files in order:

  1. .env
  2. .env.local
  3. .env.${NODE_ENV}
  4. .env.${NODE_ENV}.local

For example, when the proess.env.NODE_ENV (or options.node_env) is set to "development", dotenv-flow-webpack will be looking for and parsing (if found) the following files:

  1. .env
  2. .env.local
  3. .env.development
  4. .env.development.local

Custom Patterns

Here are a couple of examples of customizing the .env* files naming convention:

For example, if you set the pattern to ".env/[local/]env[.node_env]", dotenv-flow-webpack will look for these files instead:

  1. .env/env
  2. .env/local/env
  3. .env/env.development
  4. .env/local/env.development

… or if you set the pattern to ".env/[.node_env/].env[.node_env][.local]", the plugin will try to find and parse:

  1. .env/.env
  2. .env/.env.local
  3. .env/development/.env.development
  4. .env/development/.env.development.local

› Please refer to dotenv-flow.listFiles(options) to learn more.

@kerimdzhanov kerimdzhanov merged commit e2f140f into master Sep 25, 2023
8 checks passed
@kerimdzhanov kerimdzhanov deleted the feature/add-options-pattern branch September 25, 2023 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant