feat(dotenv-flow-webpack): add options.pattern
for customizing .env*
files' naming convention
#30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:.env
.env.local
.env.${NODE_ENV}
.env.${NODE_ENV}.local
For example, when the
proess.env.NODE_ENV
(oroptions.node_env
) is set to"development"
, dotenv-flow-webpack will be looking for and parsing (if found) the following files:.env
.env.local
.env.development
.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:.env/env
.env/local/env
.env/env.development
.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:.env/.env
.env/.env.local
.env/development/.env.development
.env/development/.env.development.local
› Please refer to
dotenv-flow.listFiles(options)
to learn more.