forked from Dokploy/dokploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.ts
42 lines (38 loc) · 905 Bytes
/
esbuild.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
import esbuild from "esbuild";
import dotenv, { type DotenvParseOutput } from "dotenv";
const result = dotenv.config({ path: ".env.production" });
function prepareDefine(config: DotenvParseOutput | undefined) {
const define = {};
// @ts-ignore
for (const [key, value] of Object.entries(config)) {
// @ts-ignore
define[`process.env.${key}`] = JSON.stringify(value);
}
return define;
}
const define = prepareDefine(result.parsed);
try {
esbuild
.build({
entryPoints: {
server: "server/server.ts",
"reset-password": "reset-password.ts",
},
bundle: true,
platform: "node",
format: "esm",
target: "node18",
outExtension: { ".js": ".mjs" },
minify: true,
sourcemap: true,
outdir: "dist",
tsconfig: "tsconfig.server.json",
define,
packages: "external",
})
.catch(() => {
return process.exit(1);
});
} catch (error) {
console.log(error);
}