import * as esbuild from 'esbuild'; import { existsSync } from 'node:fs'; const watch = process.argv.includes('--watch'); const ctxOpts = { entryPoints: ['src/main.js'], outfile: 'Assets/assistent.bundle.js', bundle: true, format: 'iife', target: ['es2020'], sourcemap: false, logLevel: 'info', }; if (watch) { const ctx = await esbuild.context(ctxOpts); await ctx.watch(); console.log('watching src/ → Assets/assistent.bundle.js'); } else { await esbuild.build(ctxOpts); if (!existsSync('Assets/assistent.bundle.js')) { process.exit(1); } console.log('built Assets/assistent.bundle.js'); }