environment-variables-webpack-plugin

1.1.0 • Public • Published

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
            })
        ],
    
    });

Package Sidebar

Install

npm i environment-variables-webpack-plugin

Weekly Downloads

1

Version

1.1.0

License

ISC

Last publish

Collaborators

  • jogaram