Skip to content

joaoreynolds/webpack-environment-loader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

webpack-environment-loader


Load app settings in JSON format depending on running environment. You can set multiple apps with their own environments settings.

Add it to your project


npm install webpack-environment-loader --save-dev

How to use it ?


  1. in your webpack.config.js

     module.exports = {
         entry: ...,
         loader: {
             appSettings: {
                 name: {myAppName}, // string, default to 'app'
                 env: {myEnv} // string, default to 'development'
             }
         },
         output: ...
     }
    
  2. in your file

     var settings = require('webpack-environment-loader!./path/to/settings')
    

Settings examples


  • with app support

      module.exports = {
          "app1": {
              "development": {
                  "api": "dev.api.com",
                  "key": "apiKey"
              },
              "production": {
                  "api": "live.api.com",
                  "key": "apiKey"
              }
          },
          "app2": {
              "development": {
                  "api": "dev.api.com",
                  "key": "apiKey"
              },
              "production": {
                  "api": "live.api.com",
                  "key": "apiKey"
              }
          }
      }
    

    only the app and environment specified in your webpack.config.js will be compiled

  • without app support

      module.exports = {
          "development": {
              "api": "dev.api.com",
              "key": "apiKey"
          },
          "test": {
              "api": "test.api.com",
              "key": "apiKey"
          },
          "production": {
              "api": "live.api.com",
              "key": "apiKey"
          }
      }
    

    only the environment specified in your webpack.config.js will be compiled

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%