forked from nullstack/nullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
57 lines (52 loc) · 1.68 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
47
48
49
50
51
52
53
54
55
56
57
const { existsSync } = require('fs')
const path = require('path')
function getOptions(target, options) {
const disk = !!options.disk;
const environment = options.environment
const entry = existsSync(path.posix.join(process.cwd(), `${target}.ts`)) ? `./${target}.ts` : `./${target}.js`
const projectFolder = process.cwd()
const configFolder = __dirname
const buildFolder = '.' + environment
const cache = !options.skipCache
const name = options.name || ''
const trace = !!options.trace
return {
target,
disk,
buildFolder,
entry,
environment,
cache,
name,
trace,
projectFolder,
configFolder
}
}
function config(platform, argv) {
const options = getOptions(platform, argv);
return {
mode: require('./webpack/mode')(options),
infrastructureLogging: require('./webpack/infrastructureLogging')(options),
entry: require('./webpack/entry')(options),
output: require('./webpack/output')(options),
resolve: require('./webpack/resolve')(options),
optimization: require('./webpack/optimization')(options),
devtool: require('./webpack/devtool')(options),
stats: require('./webpack/stats')(options),
target: require('./webpack/target')(options),
externals: require('./webpack/externals')(options),
node: require('./webpack/node')(options),
cache: require('./webpack/cache')(options),
module: require('./webpack/module')(options),
plugins: require('./webpack/plugins')(options),
experiments: require('./webpack/experiments')(options),
}
}
function server(_env, argv) {
return config('server', argv)
}
function client(_env, argv) {
return config('client', argv)
}
module.exports = [server, client]