-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
30 lines (23 loc) · 824 Bytes
/
webpack.config.js
File metadata and controls
30 lines (23 loc) · 824 Bytes
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
/* eslint no-console: "off" */
const webpackConfigs = require('./config/webpack');
const defaultConfig = 'dev';
module.exports = (configName) => {
// If there was no configuration given, 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(' ')}
`);
}
// Set the global environment
process.env.NODE_ENV = LoadedConfig.env;
const loadedInstance = new LoadedConfig();
return loadedInstance.config;
};