2026-05-19 16:05:09 +08:00
|
|
|
#!/usr/bin/env bun
|
|
|
|
|
import { bunPluginPino } from 'bun-plugin-pino'
|
|
|
|
|
import tailwindPlugin from 'bun-plugin-tailwind'
|
|
|
|
|
import { existsSync } from 'fs'
|
|
|
|
|
import { rm } from 'fs/promises'
|
|
|
|
|
|
|
|
|
|
console.log('\n🚀 Starting build process...\n')
|
|
|
|
|
|
|
|
|
|
const outdir = 'dist'
|
2026-10-19 15:35:08 +08:00
|
|
|
const target = process.argv[2] || 'all'
|
2026-05-19 16:05:09 +08:00
|
|
|
|
2026-10-19 15:35:08 +08:00
|
|
|
if (existsSync(outdir) && target === 'all') {
|
2026-05-19 16:05:09 +08:00
|
|
|
console.log(`🗑️ Cleaning previous build at ${outdir}`)
|
|
|
|
|
await rm(outdir, { recursive: true, force: true })
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 15:35:08 +08:00
|
|
|
if (target === 'all' || target === 'web') {
|
|
|
|
|
await Bun.build({
|
|
|
|
|
entrypoints: ['./apps/web/src/index.ts'],
|
|
|
|
|
root: '.',
|
|
|
|
|
target: 'bun',
|
|
|
|
|
outdir: outdir,
|
|
|
|
|
minify: true,
|
|
|
|
|
splitting: true,
|
|
|
|
|
naming: '[name].[ext]',
|
|
|
|
|
plugins: [tailwindPlugin, bunPluginPino({ transports: ['pino-pretty'] })],
|
|
|
|
|
external: ['@dbos-inc/dbos-sdk', 'pg', 'pdfkit'],
|
|
|
|
|
define: {
|
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const allWorkers = [
|
|
|
|
|
{
|
|
|
|
|
name: 'transcode',
|
|
|
|
|
entrypoint: './apps/transcode/src/index.ts',
|
|
|
|
|
naming: 'transcode-worker.[ext]',
|
2026-05-19 16:05:09 +08:00
|
|
|
},
|
2026-10-19 15:35:08 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const workersToBuild = target === 'all' ? allWorkers : allWorkers.filter((w) => w.name === target)
|
|
|
|
|
|
|
|
|
|
for (const worker of workersToBuild) {
|
|
|
|
|
await Bun.build({
|
|
|
|
|
entrypoints: [worker.entrypoint],
|
|
|
|
|
root: '.',
|
|
|
|
|
target: 'bun',
|
|
|
|
|
outdir: outdir,
|
|
|
|
|
minify: true,
|
|
|
|
|
splitting: false,
|
|
|
|
|
naming: worker.naming,
|
|
|
|
|
plugins: [bunPluginPino({ transports: ['pino-pretty'] })],
|
|
|
|
|
external: ['@dbos-inc/dbos-sdk', 'pg', 'pdfkit'],
|
|
|
|
|
define: {
|
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|