-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
tsup.config.ts
44 lines (38 loc) · 847 Bytes
/
tsup.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
import { defineConfig } from "tsup";
import { config } from "dotenv";
import { ChildProcess, spawn } from "child_process";
import { cp } from "fs";
import consola from "consola";
config();
let cProcess: ChildProcess;
export default defineConfig((options) => ({
minify: !options.watch,
entry: ["src/**/*.ts"],
clean: true,
env: {
BOT_TOKEN: process.env.BOT_TOKEN,
},
loader: {
".handlebars": "file",
},
async onSuccess() {
cp(
"src/views",
"dist/views",
{
recursive: true,
},
(err) => {
if (err) consola.error(err);
}
);
if (process.env.NODE_ENV === "production") return;
if (cProcess?.killed === false) {
cProcess.kill();
cProcess = null;
}
cProcess = spawn("node", ["dist/index.js"], {
stdio: "inherit",
});
},
}));