-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
33 lines (25 loc) · 915 Bytes
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
/* eslint no-console: "off" */
const webpackConfigs = require('./conf/webpack');
const defaultConfig = 'dev';
module.exports = (configName) => {
// If there was no configuration give, assume default
const requestedConfig = configName || defaultConfig;
// Return a new instance of the webpack config
// or the default one if it cannot be found.
let LoadedConfig = defaultConfig;
if (webpackConfigs[requestedConfig] !== undefined) {
LoadedConfig = webpackConfigs[requestedConfig];
} else {
console.warn(`
Provided environment "${configName}" was not found.
Please use one of the following ones:
${Object.keys(webpackConfigs).join(' ')}
`);
LoadedConfig = webpackConfigs[defaultConfig];
}
const loadedInstance = new LoadedConfig();
// Set the global environment
process.env.NODE_ENV = loadedInstance.env;
return loadedInstance.config;
};