Skip to content

Webpack plugin to replace in your code environment variables defined as %%var%% from a json file

Notifications You must be signed in to change notification settings

jogaram/environment-variables-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Environment variable replacing plugin for WebPack

How to use

  1. Add some variable in your code following pattern %%var%%
    new AuthConfiguration({endpoint: "%%my.var%%"})
  1. Create an environment variable set JSON file
// config/dev.json
    {
        "my": {"var": "Hello!"}
    }
  1. 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
            })
        ],
    
    });

About

Webpack plugin to replace in your code environment variables defined as %%var%% from a json file

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •