feat(pwa): new service worker declaration with custom route

This commit is contained in:
Julien Oculi 2025-05-13 13:31:42 +02:00
parent b9ab5ca132
commit d3be31d669

19
routes/sw.ts Normal file
View file

@ -0,0 +1,19 @@
import { define } from '../utils.ts'
import { bundle } from '@deno/emit'
import config from '../deno.json' with { type: 'json' }
export const handler = define.handlers(async (ctx) => {
const { code } = await bundle('./src/serviceworker/mod.ts', {
minify: true,
importMap: { imports: config.imports },
compilerOptions: {
inlineSourceMap: ctx.config.mode === 'development',
},
})
return new Response(code, {
headers: {
'Content-Type': 'text/javascript',
},
})
})