Added bun bundle
This commit is contained in:
37
scripts/build.ts
Normal file
37
scripts/build.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import fs from "node:fs/promises"
|
||||
|
||||
const normalFiles = await Promise.all([
|
||||
fs.readdir("src/commands"),
|
||||
fs.readdir("src/commands-contextmenu"),
|
||||
fs.readdir("src/components/autocomplete"),
|
||||
fs.readdir("src/components/buttons"),
|
||||
fs.readdir("src/components/modals"),
|
||||
fs.readdir("src/events/cron")
|
||||
])
|
||||
|
||||
const eventFiles = (await fs.readdir("src/events", { recursive: true })).filter(f => f.endsWith(".ts"))
|
||||
|
||||
const files = [
|
||||
normalFiles[0].map(f => `src/commands/${f}`),
|
||||
normalFiles[1].map(f => `src/commands-contextmenu/${f}`),
|
||||
normalFiles[2].map(f => `src/components/autocomplete/${f}`),
|
||||
normalFiles[3].map(f => `src/components/buttons/${f}`),
|
||||
normalFiles[4].map(f => `src/components/modals/${f}`),
|
||||
normalFiles[5].map(f => `src/events/cron/${f}`),
|
||||
eventFiles.map(f => `src/events/${f}`)
|
||||
].flat()
|
||||
|
||||
await Bun.build({
|
||||
entrypoints: ["src/index.ts", ...files],
|
||||
outdir: "dist",
|
||||
target: "bun",
|
||||
splitting: true,
|
||||
sourcemap: "external",
|
||||
naming: {
|
||||
entry: "[dir]/[name].[ext]",
|
||||
chunk: "chunk/[name]-[hash].[ext]",
|
||||
asset: "asset/[name]-[hash].[ext]"
|
||||
},
|
||||
root: "src",
|
||||
banner: "process.env.BUILD = 'true'"
|
||||
})
|
||||
Reference in New Issue
Block a user