import * as esbuild from 'esbuild'; import { readFileSync } from 'fs'; const watch = process.argv.includes('--watch'); /** @type {import('esbuild').BuildOptions} */ const common = { bundle: true, sourcemap: true, target: 'es2022', format: 'esm', logLevel: 'info', }; const configs = [ { ...common, entryPoints: ['src/background/index.ts'], outfile: 'dist/background.js', }, { ...common, entryPoints: ['src/content/inject.ts'], outfile: 'dist/content.js', }, { ...common, entryPoints: ['src/sidepanel/app.ts'], outfile: 'dist/sidepanel.js', }, { // Laeuft per Manifest in der MAIN world der Seite. Nur so ist der Konsolen-Hook // von der Content-Security-Policy der Seite ausgenommen. ...common, format: 'iife', entryPoints: ['src/content/console-hook.ts'], outfile: 'dist/console-hook.js', }, ]; if (watch) { for (const cfg of configs) { const ctx = await esbuild.context(cfg); await ctx.watch(); } console.log('Watching...'); } else { for (const cfg of configs) { await esbuild.build(cfg); } }