// Build a single, self-contained dist/index.html. // // Everything — app code, the @scure/@noble crypto libs, the QR generator, and // all CSS — is bundled and inlined so the result is one file you can save and // open offline straight from the filesystem (file://). No server, no network. import { mkdir } from 'node:fs/promises'; const FAVICON = 'data:image/svg+xml,' + encodeURIComponent( `₿` ); export async function buildHtml({ minify = true } = {}) { const result = await Bun.build({ entrypoints: ['./src/app.js'], target: 'browser', minify, }); if (!result.success) { for (const log of result.logs) console.error(log); throw new Error('bundle failed'); } let js = await result.outputs[0].text(); // Guard against a literal inside the bundle closing our tag early. js = js.replaceAll(' Bitcoin Wallet
`; } if (import.meta.main) { await mkdir('dist', { recursive: true }); const html = await buildHtml({ minify: true }); await Bun.write('dist/index.html', html); const kb = (Buffer.byteLength(html) / 1024).toFixed(0); console.log(`✓ dist/index.html written (${kb} KB) — open it offline, no server needed`); }