-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
41 lines (34 loc) · 1.37 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
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 prodPartial = require("./webpack/webpack.prod");
const { getAotPlugin } = require("./webpack/webpack.aot");
module.exports = function (options, webpackOptions) {
options = options || {};
console.log(`Running build for ${options.client ? "client" : "server"} with ${options.aot ? "AoT" : "JiT"} compilation`);
let serverConfig = webpackMerge({}, commonPartial, serverPartial, {
entry: options.aot ? "./src/bootstrap/main.server.aot.ts" : serverPartial.entry.main, // Temporary
plugins: [
getAotPlugin("server", !!options.aot)
]
});
let clientConfig = webpackMerge({}, commonPartial, clientPartial, {
plugins: [
getAotPlugin("client", !!options.aot)
]
});
if (options.aot) {
clientConfig = webpackMerge({}, clientConfig, webpackMerge({}, clientProdPartial, prodPartial));
serverConfig = webpackMerge({}, serverConfig, prodPartial);
}
const configs = [];
if (options.client) {
configs.push(clientConfig);
} else if (options.server) {
configs.push(serverConfig);
}
return configs;
};