-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.server.config.js
47 lines (43 loc) · 1.12 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
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = (env, argv) => {
const SERVER_PATH = (argv.mode === "production") ?
"./src/server/server-prod.ts" :
"./src/server/server-dev.ts";
const OUTPUT_PATH = (argv.mode === "production") ?
path.join(__dirname, 'dist_prod') :
path.join(__dirname, 'dist_dev');
return ({
entry: {
server: SERVER_PATH,
},
output: {
path: OUTPUT_PATH,
filename: 'server.js'
},
target: 'node',
node: {
// Need this when working with express, otherwise the build fails
__dirname: false, // if you don't put this is, __dirname
__filename: false, // and __filename return blank or /
},
resolve: {
extensions: [".ts", ".js"]
},
externals: [nodeExternals()], // Need this to avoid error when working with Express
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader"
}
]
}
]
}
});
}