1.0.1 • Published 2 years ago

@microbackend/plugin-env-vars v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@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}, where environment is determined by NODE_ENV. For example, if NODE_ENV is development, the values in env.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 using DefinePlugin, which can be accessed during runtime using process.env.ENV1 (const { ENV_1 } = process.env will not work).
  • If dumpToProcessEnv2 is specified, dump all environment variables to process.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