diff --git a/routes/sw.ts b/routes/sw.ts new file mode 100644 index 0000000..1ea0f18 --- /dev/null +++ b/routes/sw.ts @@ -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', + }, + }) +})