first commit
This commit is contained in:
33
webpack.config.js
Normal file
33
webpack.config.js
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint no-console: "off" */
|
||||
const webpackConfigs = require('./config/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;
|
||||
};
|
||||
Reference in New Issue
Block a user