-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.ts
64 lines (51 loc) · 1.79 KB
/
build.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
import { readdir } from "node:fs/promises";
import { $ } from "bun";
import ora from "ora";
import { routes } from "~/routes";
const buildSpinner = ora("Building").start();
await $`rm -rf dist && mkdir dist`;
// Get all directories under the plugins/ directory
const pluginDirs = await readdir("plugins", { withFileTypes: true });
await Bun.build({
entrypoints: [
"index.ts",
"cli/index.ts",
// Force Bun to include endpoints
...Object.values(routes),
// Include all plugins
...pluginDirs
.filter((dir) => dir.isDirectory())
.map((dir) => `plugins/${dir.name}/index.ts`),
],
outdir: "dist",
target: "bun",
splitting: true,
minify: false,
external: ["unzipit", "acorn"],
}).then((output) => {
if (!output.success) {
console.error(output.logs);
throw new Error("Build failed");
}
});
buildSpinner.text = "Transforming";
// Copy Drizzle migrations to dist
await $`cp -r drizzle dist/drizzle`;
// Copy plugin manifests
await $`cp plugins/openid/manifest.json dist/plugins/openid/manifest.json`;
// Copy Sharp to dist
await $`mkdir -p dist/node_modules/@img`;
await $`cp -r node_modules/@img/sharp-libvips-linux-* dist/node_modules/@img`;
await $`cp -r node_modules/@img/sharp-linux-* dist/node_modules/@img`;
// Copy unzipit and uzip-module to dist
await $`cp -r node_modules/unzipit dist/node_modules/unzipit`;
await $`cp -r node_modules/uzip-module dist/node_modules/uzip-module`;
// Copy acorn to dist
await $`cp -r node_modules/acorn dist/node_modules/acorn`;
// Copy the Bee Movie script from pages
await $`cp beemovie.txt dist/beemovie.txt`;
// Copy package.json
await $`cp package.json dist/package.json`;
// Copy cli/theme.json
await $`cp cli/theme.json dist/cli/theme.json`;
buildSpinner.stop();