Files
beat-pocket/esbuild.config.mjs
Zebratic 80c2aa0401 Fix: bundle output to extension/dist/content/, update manifest path
The esbuild outdir was relative to cwd, so it landed at project root
(dist/content/) on a project-root build, not under the extension dir.
Fix:
- esbuild writes to extension/dist/content/
- manifest.json content_scripts.js → dist/content/index.js
- Keeps the extension self-contained so Chrome --load-extension works
  without any external files
2026-07-11 02:29:25 +00:00

32 lines
929 B
JavaScript

// esbuild config — bundles TS entry to a single content script
import * as esbuild from 'esbuild';
import { existsSync, mkdirSync } from 'node:fs';
const isWatch = process.argv.includes('--watch');
// Bundle lives under extension/dist/content/ so Chrome can load the
// extension directory without needing any files outside it.
const outdir = 'extension/dist/content';
if (!existsSync(outdir)) mkdirSync(outdir, { recursive: true });
const ctx = await esbuild.context({
entryPoints: ['extension/content/index.ts'],
bundle: true,
format: 'iife',
target: 'chrome109',
outfile: `${outdir}/index.js`,
sourcemap: 'linked',
logLevel: 'info',
banner: { js: '/* Beat Pocket content script */' },
});
if (isWatch) {
await ctx.watch();
console.log('esbuild watching…');
} else {
const r = await ctx.rebuild();
await ctx.dispose();
if (r.errors.length) process.exit(1);
console.log('build complete');
}