Load app settings in JSON format depending on running environment. You can set multiple apps with their own environments settings.
npm install webpack-env-loader --save-dev
-
in your webpack.config.js
module.exports = { entry: ..., loader: { appSettings: { name: {myAppName}, // string, default to 'app' env: {myEnv} // string, default to 'development' } }, output: ... }
-
in your file
var settings = require('webpack-env-loader!./path/to/settings')
-
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