forked from bayesimpact/docker-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
46 lines (38 loc) · 1.12 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict'
require('es6-promise').polyfill()
var path = require('path')
var args = require('minimist')(process.argv.slice(2))
// List of allowed environments.
var allowedEnvs = ['dev', 'dist', 'test']
// Set the correct environment.
if (args._.length > 0 && args._.indexOf('start') !== -1) {
process.env.REACT_WEBPACK_ENV = 'test'
} else if (!process.env.REACT_WEBPACK_ENV) {
process.env.REACT_WEBPACK_ENV = 'dev'
}
// Get available configurations
var configs = {
dev: require(path.join(__dirname, 'cfg/dev')),
dist: require(path.join(__dirname, 'cfg/dist')),
test: require(path.join(__dirname, 'cfg/test')),
}
/**
* Get an allowed environment
* @param {String} env
* @return {String}
*/
function getValidEnv(env) {
var isValid = env && env.length > 0 && allowedEnvs.indexOf(env) !== -1
return isValid ? env : 'dev'
}
/**
* Build the webpack configuration
* @param {String} env Environment to use
* @return {Object} Webpack config
*/
function buildConfig(env) {
var usedEnv = getValidEnv(env)
return configs[usedEnv]
}
process.traceDeprecation = true
module.exports = buildConfig(process.env.REACT_WEBPACK_ENV)