forked from maciejtreder/ng-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
54 lines (46 loc) · 1.62 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
const webpackMerge = require('webpack-merge');
const commonPartial = require('./webpack/webpack.common');
const clientPartial = require('./webpack/webpack.client');
const serverPartial = require('./webpack/webpack.server');
const prodPartial = require('./webpack/webpack.prod');
const dllPartial = require('./webpack/webpack.dll');
const testPartial = require('./webpack/webpack.test');
const { getAotPlugin } = require('./webpack/webpack.aot');
module.exports = function (options, webpackOptions) {
options = options || {};
webpackOptions = webpackOptions || {};
const configs = [];
if (options.aot) {
console.log(`Running build for ${options.client ? 'client' : 'server'}`)
}
const serverConfig = webpackMerge({}, commonPartial(options), serverPartial, {
plugins: [
getAotPlugin('server', !!options.aot)
]
});
var clientConfig = webpackMerge({}, commonPartial(options), clientPartial, {
plugins: [
getAotPlugin('client', (!!options.aot))
]
});
if (webpackOptions.p) {
clientConfig = webpackMerge({}, clientConfig, prodPartial);
}
if (options.dll) {
configs.push(webpackMerge({}, commonPartial(options), dllPartial, {
plugins: [
getAotPlugin('client', true)
]
}));
}
if (options.server) {
configs.push(serverConfig);
}
if (options.client) {
configs.push(clientConfig);
}
if (options.test) {
configs.push(webpackMerge({}, testPartial));
}
return configs;
}