-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
81 lines (76 loc) · 2.35 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
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
76
77
78
79
80
81
import CircularDependencyPlugin from "circular-dependency-plugin"
import * as fs from "fs"
import * as path from "path"
import webpack from "webpack"
import "webpack-dev-server"
const workers = fs
.readdirSync("./src/workers", { withFileTypes: true })
.filter((entry) => entry.isFile() && entry.name !== "index.ts")
.map(({ name }) => name.replace(".ts", ""))
.map((name) => [`workers/${name}`, `./src/workers/${name}.ts`])
export default (env: string, argv: Record<string, string>): webpack.Configuration => {
const plugins = []
const native = process.env.IS_NATIVE === "true"
if (process.env.CYCLE_CHECK) {
plugins.push(
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /node_modules/,
// include specific files based on a RegExp
include: /src/,
// add errors to webpack instead of warnings
failOnError: false,
})
)
}
return {
entry: {
app: `./src/${native ? "native" : "web"}.ts`,
...Object.fromEntries(workers),
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.js$/,
enforce: "pre",
use: ["source-map-loader"],
},
],
},
resolve: {
extensions: [".ts", ".js"],
symlinks: false,
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "static"),
},
devtool:
argv.mode === "development" ? "eval-cheap-module-source-map" : "nosources-source-map",
devServer: {
allowedHosts: "all",
https: false,
compress: true,
hot: false,
liveReload: false,
open: false,
port: 8000,
client: {
webSocketURL: "auto://0.0.0.0:0/ws",
},
static: {
directory: path.join(__dirname, "static"),
},
},
stats: {
assets: false,
modules: false,
},
plugins,
}
}