-
Notifications
You must be signed in to change notification settings - Fork 247
Expand file tree
/
Copy pathesbuild.config.mjs
More file actions
84 lines (79 loc) · 2.17 KB
/
esbuild.config.mjs
File metadata and controls
84 lines (79 loc) · 2.17 KB
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
82
83
84
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const isProduction = process.env.NODE_ENV === "production";
// Path aliases matching tsconfig paths (baseUrl: src)
const aliases = {
common: path.resolve(__dirname, "src/common"),
renderer: path.resolve(__dirname, "src/renderer"),
main: path.resolve(__dirname, "src/main"),
vendor: path.resolve(__dirname, "src/vendor"),
static: path.resolve(__dirname, "src/static"),
};
// Main process config
export const mainConfig = {
entryPoints: {
main: "src/main/index.ts",
"inject-game": "src/main/inject/inject-game.ts",
"inject-captcha": "src/main/inject/inject-captcha.ts",
"inject-preload": "src/main/inject/inject-preload.ts",
},
bundle: true,
platform: "node",
target: "node24",
outdir: "dist/main",
// NOTE: Electron supports ESM for main process. Migrating from CJS to ESM is an optional follow-up.
outExtension: { ".js": ".bundle.cjs" },
format: "cjs",
sourcemap: true,
minify: isProduction,
metafile: true,
external: ["electron", "original-fs"],
alias: aliases,
define: {
"process.env.NODE_ENV": JSON.stringify(
isProduction ? "production" : "development"
),
},
};
// Browser polyfills for Node.js built-ins
const browserAliases = {
...aliases,
querystring: "querystring-es3",
events: "events",
url: "url",
};
// Renderer process config
export const rendererConfig = {
entryPoints: {
renderer: "src/renderer/index.tsx",
},
bundle: true,
platform: "browser",
target: "chrome144", // Match Electron 40's Chromium version
outdir: "dist/renderer",
outExtension: { ".js": ".bundle.js" },
format: "iife",
globalName: "LIB",
sourcemap: true,
minify: isProduction,
metafile: true,
external: ["systeminformation"],
alias: browserAliases,
loader: {
".png": "file",
".svg": "file",
".woff": "file",
".woff2": "file",
".ttf": "file",
".css": "css",
},
assetNames: "[name]-[hash]",
define: {
"process.env.NODE_ENV": JSON.stringify(
isProduction ? "production" : "development"
),
global: "window",
},
inject: ["./esbuild-shims.js"],
};