chore: use mjs for sw
This commit is contained in:
parent
ba274641ff
commit
bcc1574e8f
2 changed files with 4 additions and 4 deletions
|
@ -8,7 +8,7 @@ export default defineConfig({
|
|||
integrations: [
|
||||
sitemap(),
|
||||
serviceWorker({
|
||||
path: './src/sw.ts',
|
||||
path: './src/sw.mjs',
|
||||
assetCachePrefix: 'ayco-personal-site',
|
||||
excludeRoutes: [
|
||||
'/threads'
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
*/
|
||||
const cacheName = `${__prefix ?? 'app'}-v${__version ?? '000'}`
|
||||
|
||||
const addResourcesToCache = async (resources: string[]) => {
|
||||
const addResourcesToCache = async (resources) => {
|
||||
const cache = await caches.open(cacheName);
|
||||
console.log('[personal-sw]: adding resources to cache...', resources)
|
||||
await cache.addAll(new Set([...resources]));
|
||||
};
|
||||
|
||||
const putInCache = async (request: Request, response: Response) => {
|
||||
const putInCache = async (request, response) => {
|
||||
const cache = await caches.open(cacheName);
|
||||
console.log('[personal-sw]: adding one response to cache...', request.url)
|
||||
// if exists, replace
|
||||
|
@ -25,7 +25,7 @@ const putInCache = async (request: Request, response: Response) => {
|
|||
};
|
||||
|
||||
|
||||
const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl }: {request: Request, preloadResponsePromise: Promise<any>, fallbackUrl: string}) => {
|
||||
const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl }) => {
|
||||
|
||||
const cache = await caches.open(cacheName);
|
||||
|
Loading…
Reference in a new issue