forked from 4Science/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
45 lines (36 loc) · 1.26 KB
/
webpack.config.ts
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
const webpackMerge = require('webpack-merge');
const prodPartial = require('./webpack/webpack.prod');
module.exports = (env, options) => {
env = env || {};
const commonPartial = require('./webpack/webpack.common')(env);
const clientPartial = require('./webpack/webpack.client')(env);
const { getAotPlugin } = require('./webpack/webpack.aot')(env);
const { getServerWebpackPartial } = require('./webpack/webpack.server')(env);
if (env.aot) {
console.log(`Running build for ${env.client ? 'client' : 'server'} with AoT Compilation`);
}
const serverPartial = getServerWebpackPartial(env.aot);
let serverConfig = webpackMerge({}, commonPartial, serverPartial, {
plugins: [
getAotPlugin('server', !!env.aot)
]
});
let clientConfig = webpackMerge({}, commonPartial, clientPartial, {
plugins: [
getAotPlugin('client', !!env.aot)
]
});
if (options.mode === 'production') {
serverConfig = webpackMerge({}, serverConfig, prodPartial);
clientConfig = webpackMerge({}, clientConfig, prodPartial);
}
const configs = [];
if (!env.aot) {
configs.push(clientConfig, serverConfig);
} else if (env.client) {
configs.push(clientConfig);
} else if (env.server) {
configs.push(serverConfig);
}
return configs;
};