-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-server.config.js
69 lines (65 loc) · 1.63 KB
/
webpack-server.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
63
64
65
66
67
68
69
const webpack = require('webpack');
const path = require('path');
const {join, resolve} = require('path');
const loaders = require('./src/webpack/loaders');
module.exports = {
target: 'node',
entry: {
server: ['./src/server/index.ts'],
},
output: {
filename: 'index.js',
path: resolve(join(__dirname, 'dist-server')),
libraryTarget: 'commonjs2',
},
resolve: {
extensions: ['.ts', '.js', '.json'],
},
module: {
rules: [
loaders.tsjit,
loaders.html,
loaders.css
]
},
plugins: [
new webpack.DefinePlugin({ "global.GENTLY": false }),
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators for Windows and MacOS
/(.+)?angular(\\|\/)core(.+)?/,
path.join(__dirname, 'src'), // location of your src
{} // a map of your routes
),
],
externals: [
'@angular/animations',
'@angular/cli',
'@angular/common',
'@angular/compiler',
'@angular/compiler-cli',
'@angular/core',
'@angular/forms',
'@angular/http',
'@angular/platform-browser',
'@angular/router',
'@angular/tsc-wrapped',
'@angular/service-worker',
'angular-ssr',
'express',
'ng2-file-drop',
function(context, request, callback) {
const exclusions = [/\@ngrx/, /rxjs/, /zone\.js/, /reflect-metadata/];
if (exclusions.some(expr => expr.test(request))) {
callback(null, `commonjs ${request.replace(/^.*?(\\|\/)node_modules(\\|\/)/, String())}`);
}
else {
callback();
}
},
],
node: {
process: true,
__dirname: true,
__filename: true
}
};