Build service worker

This commit is contained in:
Armin Ronacher 2025-06-23 23:17:03 +02:00
parent b39f63ea73
commit 20d3758d38
2 changed files with 17 additions and 0 deletions

View file

@ -37,6 +37,14 @@ async function build() {
outfile: 'public/bundle/test.js',
});
// Build service worker
await esbuild.build({
...prodOptions,
entryPoints: ['src/client/sw.ts'],
outfile: 'public/sw.js',
format: 'iife', // Service workers need IIFE format
});
console.log('Client bundles built successfully');
} catch (error) {
console.error('Build failed:', error);

View file

@ -43,9 +43,17 @@ async function startBuilding() {
outfile: 'public/bundle/test.js',
});
const swContext = await esbuild.context({
...devOptions,
entryPoints: ['src/client/sw.ts'],
outfile: 'public/sw.js',
format: 'iife', // Service workers need IIFE format
});
// Start watching
await clientContext.watch();
await testContext.watch();
await swContext.watch();
console.log('ESBuild watching client bundles...');
// Start other processes
@ -67,6 +75,7 @@ async function startBuilding() {
console.log('\nStopping all processes...');
await clientContext.dispose();
await testContext.dispose();
await swContext.dispose();
processes.forEach(proc => proc.kill());
process.exit(0);
});