-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
55 lines (53 loc) · 1.59 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
54
55
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const nodeExternals = require("webpack-node-externals");
const fs = require("fs");
const webpack = require("webpack");
const console = require("console");
if (!fs.existsSync(path.join(__dirname, "backend", "env.json"))) {
fs.writeFileSync(path.join(__dirname, "backend", "env.json"), "{}");
}
const webpackConfig = {
name: "server",
target: "node",
externals: [nodeExternals()],
entry: {
index: "./backend/src/Server.ts",
},
output: {
filename: "[name].js",
path: path.join(__dirname, "/dist/backend"),
devtoolModuleFilenameTemplate: "[absolute-resource-path]",
},
devtool: process.env.NODE_ENV === "production" ? undefined : "cheap-source-map",
module: {
rules: [
{
test: /\.ts$/,
use: "ts-loader",
exclude: [path.join(__dirname, "./node_modules"), path.join(__dirname, "./frontend")],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
fallback: {
fs: false,
net: false,
},
},
plugins: [
new CopyPlugin({
patterns: [
{
from: path.join(__dirname, "backend", "env.json"),
to: path.join(__dirname, "dist", "backend", "env.json"),
},
],
}),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
}),
],
};
module.exports = webpackConfig;