JSPM

inline-environment-variables-webpack-plugin

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1339
  • Score
    100M100P100Q114623F
  • License MIT

webpack plugin to inline all environment variables

Package Exports

  • inline-environment-variables-webpack-plugin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (inline-environment-variables-webpack-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

inline-environment-variables-webpack-plugin

Plugin which replaces all instances of process.env.*** with the environment variable value.

Install

npm install --save-dev inline-environment-variables-webpack-plugin

Usage

Inline all enviroment variables

If you would like to inline all enviroment variables then you can just instantiate the plugin without passing any config, as in the following example.

var InlineEnviromentVariablesPlugin = require('inline-environment-variables-webpack-plugin');

var webpackConfig = {
  plugins: [
    new InlineEnviromentVariablesPlugin()
  ],
  // other webpack config ...
};

Inline only selected enviroment variables

You can optionally pass a config to select which enviroment variables you would like to inline.

A config can be either a string an object or an array.

string config

A string config is defined like

new InlineEnviromentVariablesPlugin('NODE_ENV')

The above config will inline process.env.NODE_ENV with the value of process.env.NODE_ENV at build time

object config

an object config is defined like

new InlineEnviromentVariablesPlugin({ NODE_ENV: 'production' });

The above config will inline process.env.NODE_ENV with the value specified in the config. So in the above example it would change it to 'production';

array config

and array config is just a list of string and object configs. It would be defined like

new InlineEnviromentVariablesPlugin([
  'SOME_VAR',
  'ANOTHER_ONE',
  { 
    NODE_ENV: 'production',
    ONE_MORE: true
  }
]);