package
A plugin for loading configuration into webpack based on environment
npm install webpack-env-loader-pluginGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
A plugin that extends DefinePlugin to help load configuration based on environment.
First, install with npm:
npm install webpack-env-loader-plugin --saveAdd an instance of the plugin to webpack.config.js:
const EnvLoaderPlugin = require("webpack-env-loader-plugin");
module.exports = {
...
plugins: [
new EnvLoaderPlugin(options)
]
};EnvLoaderPlugin will pick up configuration from files with the pattern config.{env}.json, or a custom pattern you define, in this order:
config.default.json (or config.default.yml, if you're into that)config.{env}.json, where {env} is process.env.NODE_ENVIn your javascript files processed by webpack, all configuration values are exposed under a global object (__CONFIG__ by default):
if (__CONFIG__.FOO) {
console.log("foo");
}If you want to trigger webpack builds with different environments, just make sure you set NODE_ENV:
NODE_ENV=production webpackDefault: process.env.NODE_ENV
You can use this option to override process.env.NODE_ENV if you want to specify it explicitly.
Default: false
Add configuration that will set React to production mode if env is "production".
Default: process.cwd()
This is the path in which to look for config files.
Default: config.{env}.json
Pattern to file config files. {env} is replaced by whatever env is.
Default: "CONFIG"
Object that prefixes your config variables, so they don't pollute global state. If you are using eslint, make sure you add it to globals.
Default: true
Load config.default.json (or whatever your filePattern is with {env} set to default) before loading other configuration files.
Default: null
If you specify a path in this option, the plugin will load the file and override all other configuration EXCEPT process.env;
Default: true
Override configuration with values from process.env if they are found.
Default: true
Log progress to console.
Estimated unpacked size across 49 packages.
25.9 MB
Includes dependencies.
5 direct · 4 outdated
^0.3.0
2.9.1
^1.1.2
1.4.0
^0.2.6
0.3.0
^2.2.1
5.112.2
^2.0.1
5.1.0