-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ts
42 lines (34 loc) · 909 Bytes
/
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
import { logger } from '@/utils'
import { rm } from 'node:fs/promises'
const outDir = './dist'
async function build() {
const entrypoints = ['./src/bot.ts']
logger.debug('Building with entrypoints:', entrypoints)
const result = await Bun.build({
entrypoints: entrypoints,
outdir: outDir,
minify: true,
target: 'bun',
root: '.',
sourcemap: 'external',
external: ['discord.js']
})
if (!result.success) {
logger.error(result)
process.exit(1)
}
logger.debug('Build completed successfully!')
logger.debug('Output files:')
for (const output of result.outputs) {
logger.debug(output.path)
}
}
async function cleanOutdir() {
try {
await rm(outDir, { recursive: true, force: true })
logger.debug(`Cleaned ${outDir}`)
} catch (error: any) {
if (error.code !== 'ENOENT') throw error
}
}
cleanOutdir().then(build).catch(console.error)