// Builds the browser extension into extension/dist (load that folder // unpacked at chrome://extensions, Developer mode on). // bun extension/build.js import { rm, mkdir, cp } from 'node:fs/promises'; import { join, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; const here = dirname(fileURLToPath(import.meta.url)); const out = join(here, 'dist'); await rm(out, { recursive: true, force: true }); await mkdir(out, { recursive: true }); const r = await Bun.build({ entrypoints: ['background.js', 'popup.js', 'prompt.js'].map((f) => join(here, 'src', f)), outdir: out, target: 'browser', format: 'esm', minify: false, }); if (!r.success) { for (const l of r.logs) console.error(l); process.exit(1); } for (const f of ['content.js', 'provider.js', 'popup.html', 'prompt.html', 'ui.css']) await cp(join(here, 'src', f), join(out, f)); await cp(join(here, 'manifest.json'), join(out, 'manifest.json')); await cp(join(here, '..', 'static', 'icon-192.png'), join(out, 'icon-192.png')); await cp(join(here, '..', 'static', 'PublicSans.woff2'), join(out, 'PublicSans.woff2')); console.log('extension built →', out);