-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.server.config.ts
75 lines (61 loc) · 1.65 KB
/
webpack.server.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import * as path from "path";
import * as webpack from "webpack";
import NodemonPlugin from "nodemon-webpack-plugin";
import nodeExternals from "webpack-node-externals";
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
export function createConfig() {
const isProduction = process.env.NODE_ENV === "production";
console.log(`Server isProduction: ${isProduction}`);
const config: webpack.Configuration = {
mode: isProduction ? "production" : "development",
context: path.resolve(__dirname, "server"),
entry: {
server: isProduction ? "./bootstrap.prod" : "./bootstrap.dev",
},
target: "node",
node: {
__dirname: false,
__filename: false,
},
externals: [nodeExternals(), "./public/ssr"],
output: {
path: path.resolve("./dist"),
publicPath: "/",
filename: "[name].js",
libraryTarget: "commonjs",
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".jsx"],
plugins: [new TsconfigPathsPlugin({})],
alias: {
"./public/index.html": path.resolve(
__dirname,
"dist/public/index.html"
),
},
},
devtool: "nosources-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: "ts-loader",
},
{
test: /\.(html)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "raw-loader",
},
],
},
optimization: {
minimize: false,
},
plugins: [],
};
if (!isProduction) {
config.plugins?.push(new NodemonPlugin({ nodeArgs: ["--inspect"] }));
}
return config;
}
export default createConfig;