Inline Environment Variables Webpack Plugin

raw JSON →
1.2.1 verified Sat Apr 25 auth: no javascript

A webpack plugin that replaces all instances of `process.env.***` with actual environment variable values at build time. Current stable version is 1.2.1, with infrequent releases. Key features: inline all environment variables by default, select specific variables using string/object/array config, or define static values. No runtime dependencies. Simpler alternative to webpack's DefinePlugin for basic env inlining, but limited to environment variables only and primarily intended for development/debugging use cases. Last updated in 2017.

error Module not found: Error: Can't resolve 'inline-environment-variables-webpack-plugin'
cause Plugin not installed or misspelled package name.
fix
Run npm install --save-dev inline-environment-variables-webpack-plugin and check import path.
error TypeError: InlineEnvironmentVariablesPlugin is not a constructor
cause Using ESM import syntax (import from) instead of CommonJS require.
fix
Use const InlineEnvironmentVariablesPlugin = require('inline-environment-variables-webpack-plugin');
error ReferenceError: process is not defined
cause Plugin not applied to bundle (e.g., missing in webpack config plugins array).
fix
Add new InlineEnvironmentVariablesPlugin() to the plugins array in webpack.config.js.
breaking v1.2.0 and earlier used wrong export name `InlineEnviromentVariablesPlugin` (missing 'n'). v1.2.1 fixed this to `InlineEnvironmentVariablesPlugin`.
fix Upgrade to v1.2.1 (npm install inline-environment-variables-webpack-plugin@latest) and rename imports to `InlineEnvironmentVariablesPlugin`.
gotcha Plugin only replaces process.env.*** calls with string values; objects/functions will be serialized to string (e.g., 'true' for boolean true).
fix Use webpack's DefinePlugin or EnvironmentPlugin for complex value replacement.
deprecated No updates since 2017; consider using webpack's built-in EnvironmentPlugin or DotenvPlugin for modern projects.
fix Use webpack.EnvironmentPlugin or @maika/env-development or dotenv-webpack instead.
gotcha If environment variable is undefined at build time, plugin replaces process.env.VAR with undefined string, possibly causing runtime errors.
fix Ensure all referenced env vars are set; use config object to provide defaults.
npm install inline-environment-variables-webpack-plugin
yarn add inline-environment-variables-webpack-plugin
pnpm add inline-environment-variables-webpack-plugin

Basic usage: instantiate plugin without config to replace all process.env.* calls with actual environment values at build time.

// webpack.config.js
const InlineEnvironmentVariablesPlugin = require('inline-environment-variables-webpack-plugin');

module.exports = {
  plugins: [
    new InlineEnvironmentVariablesPlugin()
  ]
};