-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
62 lines (53 loc) · 2.09 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
58
59
60
61
62
const ngtools = require("@ngtools/webpack")
const webpackMerge = require("webpack-merge")
const commonPartial = require("./webpack/webpack.common")
const clientPartial = require("./webpack/webpack.client")
const clientProdPartial = require("./webpack/webpack.client.prod")
const serverPartial = require("./webpack/webpack.server")
const serverProdPartial = require("./webpack/webpack.server.prod")
const devPartial = require("./webpack/webpack.dev")
const prodPartial = require("./webpack/webpack.prod")
const testPartial = require("./webpack/webpack.test")
const { getAotPlugin } = require("./webpack/webpack.aot")
module.exports = function (options, webpackOptions) {
options = options || {}
console.log(`Running build for ${options.client ? "client" : options.server ? "server" : "test"} with ${options.aot ? "AoT" : "JiT"} compilation`)
let serverConfig = webpackMerge({}, commonPartial, serverPartial, {
plugins: [
getAotPlugin("server", !!options.aot)
]
})
let clientConfig = webpackMerge({}, commonPartial, clientPartial, {
entry: options.aot ? {
"main": "./src/bootstrap/main.ts",
"polyfills": "./src/polyfills/polyfills.browser.ts",
"styles": "./src/assets/css/styles.styl",
"webworker": "./src/bootstrap/main.worker.aot.ts"
} : clientPartial.entry, // Temporary
plugins: [
getAotPlugin("client", !!options.aot)
]
})
let testConfig = webpackMerge({}, commonPartial, testPartial, {
plugins: [
getAotPlugin("test", !!options.aot)
]
})
if (options.aot) {
clientConfig = webpackMerge({}, clientConfig, clientProdPartial, prodPartial)
serverConfig = webpackMerge({}, serverConfig, serverProdPartial, prodPartial)
} else {
clientConfig = webpackMerge({}, clientConfig, devPartial)
serverConfig = webpackMerge({}, serverConfig, devPartial)
testConfig = webpackMerge({}, testConfig, devPartial)
}
const configs = []
if (options.client) {
configs.push(clientConfig)
} else if (options.server) {
configs.push(serverConfig)
} else if (options.test) {
configs.push(testConfig)
}
return configs
}