aboutsummaryrefslogtreecommitdiffstats
path: root/extension/build.js
blob: e9013e04c81d704447aabb8f780a184a6b6aa5bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// 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);