environment-variables-webpack-plugin
v1.1.0
Published
Webpack plugin to replace in your code environment variables defined as %%var%% from a json file
Maintainers
Readme
Environment variable replacing plugin for WebPack
How to use
- Add some variable in your code following pattern %%var%%
new AuthConfiguration({endpoint: "%%my.var%%"})- Create an environment variable set JSON file
// config/dev.json
{
"my": {"var": "Hello!"}
}- Add reference to the plugin from your webpack configuration
//config/webpack.dev.js
var webpackMerge = require('webpack-merge');
var EnvironmentVariablesPlugin = require('environment-variables-webpack-plugin');
var commonConfig = require('./webpack.common.js');
module.exports = webpackMerge(commonConfig, {
plugins: [
new EnvironmentVariablesPlugin({
optionsFile: 'config/dev.json',
chunks: ['angularApp'],
skipUndefinedVars: true // default false
})
],
});