-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
35 lines (33 loc) · 1.07 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
import { getCommonConfig } from './config/webpack.common.js'
import { getDevelopmentConfig } from './config/webpack.dev.js'
import { getBuildConfig } from './config/webpack.build.js'
import { getProductionConfig } from './config/webpack.prod.js'
import { getReleaseConfig } from './config/webpack.release.js'
import { merge } from 'webpack-merge'
const isArray = tar => Object.prototype.toString.call(tar) === '[object Array]'
export const getWebpackConfig = (env, args) => {
const { mode } = env
const commonConfig = getCommonConfig()
let specificConfig = null
switch (mode) {
case 'production':
specificConfig = getProductionConfig()
break
case 'development':
specificConfig = getDevelopmentConfig()
break
case 'build':
specificConfig = getBuildConfig()
break
case 'release':
specificConfig = getReleaseConfig()
break
default:
break
}
if (isArray(specificConfig)) {
return specificConfig.map(config => merge(commonConfig, config, {}))
} else {
return merge(commonConfig, specificConfig, {})
}
}