feat(pwa): new service worker declaration with custom route
This commit is contained in:
parent
b9ab5ca132
commit
d3be31d669
19
routes/sw.ts
Normal file
19
routes/sw.ts
Normal 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',
|
||||
},
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue