picoclaw/pkg/miniapp/frontend/build.mjs
dj-oyu b63d0db489 fix: add bun install to go:generate and packages:bundle to build
- Split go:generate into `bun install` + `bun run build` so deps are
  always available before bundling (fixes build on clean checkout)
- Add `packages: 'bundle'` to Bun.build() so node_modules are resolved
  and bundled into the output (required for marked + highlight.js)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 16:15:17 +09:00

28 lines
754 B
JavaScript

import { copyFile, mkdir, rm } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const rootDir = path.dirname(fileURLToPath(import.meta.url));
const srcDir = path.join(rootDir, 'src');
const outDir = path.join(rootDir, '..', 'static', 'dist');
await rm(outDir, { recursive: true, force: true });
await mkdir(outDir, { recursive: true });
const result = await Bun.build({
entrypoints: [path.join(srcDir, 'app.js')],
outdir: outDir,
target: 'browser',
format: 'iife',
sourcemap: 'none',
packages: 'bundle',
});
if (!result.success) {
for (const log of result.logs) {
console.error(log);
}
process.exit(1);
}
await copyFile(path.join(srcDir, 'map.js'), path.join(outDir, 'map.js'));