1.0.1 • Published 3 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
3 years ago
1.0.1
3 years ago
1.0.1-alpha.27
3 years ago
1.0.1-alpha.43
3 years ago
1.0.1-alpha.42
3 years ago
1.0.1-alpha.41
3 years ago
1.0.1-alpha.31
3 years ago
1.0.1-alpha.15
3 years ago
1.0.1-alpha.0
4 years ago
1.0.0
4 years ago
1.0.1-alpha.135
4 years ago
1.0.1-alpha.133
4 years ago
1.0.1-alpha.131
4 years ago
1.0.1-alpha.129
4 years ago
1.0.1-alpha.126
4 years ago
1.0.1-alpha.124
4 years ago
1.0.1-alpha.123
4 years ago
1.0.1-alpha.122
4 years ago
1.0.1-alpha.120
4 years ago
1.0.1-alpha.113
4 years ago
1.0.1-alpha.108
4 years ago
1.0.1-alpha.107
4 years ago
1.0.1-alpha.101
4 years ago