1.0.1 • Published 2 years ago
@microbackend/plugin-env-vars v1.0.1
@microbackend/plugin-env-vars
Microbackend plugin to inject environment variables into process.env
.
Installation
npx microbackend plugin add @microbackend/plugin-env-vars
Usage
import createPluginConfig from "@microbackend/plugin-core/build/webpack.build";
await createPluginConfig({
pluginOptions: {
"@microbackend/plugin-env-vars": {
additionalEnvVariables: { ENV_2: "2" },
dumpToProcessEnv2: true,
requiredEnvVariables: ["ENV_1", "ENV_2"],
},
},
});
The above configuration does the following:
- Extract the environment variables in
env.${environment}
, whereenvironment
is determined byNODE_ENV
. For example, ifNODE_ENV
isdevelopment
, the values inenv.development
will be used. - Extract additional variables passed to
additionalEnvVariables
. - Check that the keys specified to
requiredEnvVariables
point to valid environment variable values. If they do not, an error will be thrown. This is useful for compile-time checks against missing environment variables. - Inject all the collected variables into
process.env
usingDefinePlugin
, which can be accessed during runtime usingprocess.env.ENV1
(const { ENV_1 } = process.env
will not work). - If
dumpToProcessEnv2
is specified, dump all environment variables toprocess.env2
as well. This is useful during development when we want to view all currently available variables (e.g.console.log(process.env2)
).
1.0.1-alpha.26
2 years ago
1.0.1
2 years ago
1.0.1-alpha.27
2 years ago
1.0.1-alpha.43
2 years ago
1.0.1-alpha.42
2 years ago
1.0.1-alpha.41
2 years ago
1.0.1-alpha.31
2 years ago
1.0.1-alpha.15
2 years ago
1.0.1-alpha.0
2 years ago
1.0.0
2 years ago
1.0.1-alpha.135
2 years ago
1.0.1-alpha.133
2 years ago
1.0.1-alpha.131
2 years ago
1.0.1-alpha.129
2 years ago
1.0.1-alpha.126
2 years ago
1.0.1-alpha.124
2 years ago
1.0.1-alpha.123
2 years ago
1.0.1-alpha.122
2 years ago
1.0.1-alpha.120
2 years ago
1.0.1-alpha.113
2 years ago
1.0.1-alpha.108
2 years ago
1.0.1-alpha.107
2 years ago
1.0.1-alpha.101
2 years ago