From d5f92e71a244cc14c24d3c17e3d03d8a3487773b Mon Sep 17 00:00:00 2001 From: ayoayco Date: Sat, 17 Aug 2024 09:57:40 +0200 Subject: [PATCH] chore: move sw file to test new config --- astro.config.mjs | 2 +- example_sw.ts => src/example_sw.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename example_sw.ts => src/example_sw.ts (91%) diff --git a/astro.config.mjs b/astro.config.mjs index 36c0c5b..3553672 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -10,7 +10,7 @@ export default defineConfig({ site: 'https://ayo.ayco.io', integrations: [ serviceWorker({ - path: "./example_sw.ts", + path: "./src/example_sw.ts", assetCachePrefix: 'cozy-reader', customRoutes: [ '/threads' diff --git a/example_sw.ts b/src/example_sw.ts similarity index 91% rename from example_sw.ts rename to src/example_sw.ts index 0ad543c..744d419 100644 --- a/example_sw.ts +++ b/src/example_sw.ts @@ -1,11 +1,11 @@ -import { log } from "./src/utils"; +import { log } from "./utils"; /** - * Note: @ayco/astro-sw integration injects variables `__prefix`, `__version`, & `__assets` + * Note: @ayco/astro-sw integration injects variables `__astro_sw_cache_prefix__`, `__astro_sw_version__`, & `__astro_sw_assets__` * -- find usage in package readme; `astro.config.mjs` integrations * @see https://ayco.io/n/@ayco/astro-sw */ -const cacheName = `${__prefix ?? 'app'}-v${__version ?? '000'}` +const cacheName = `${__astro_sw_cache_prefix__ ?? 'app'}-v${__astro_sw_version__ ?? '000'}` const addResourcesToCache = async (resources) => { const cache = await caches.open(cacheName); console.log('adding resources to cache...', resources) @@ -80,7 +80,7 @@ self.addEventListener('install', (event) => { event.waitUntil( addResourcesToCache([ './', - ...(__assets ?? []) + ...(__astro_sw_assets__ ?? []) ]) ); });