From 13978f8380f6e84edd6f5ab087c228cffecb498c Mon Sep 17 00:00:00 2001 From: ayoayco Date: Sat, 17 Aug 2024 21:18:30 +0200 Subject: [PATCH] chore: move example_sw.js to src --- README.md | 2 +- astro.config.mjs | 2 +- example_sw.js => src/example_sw.js | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) rename example_sw.js => src/example_sw.js (96%) diff --git a/README.md b/README.md index 080f691..b87ebf3 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ The integration accepts a configuration object of type `ServiceWorkerConfig` wit ## Example sw.js -You can find an example service worker (`example_sw.js`) in the [repository](https://ayco.io/gh/astro-sw). +You can find an example service worker (`src/example_sw.js`) in the [repository](https://ayco.io/gh/astro-sw). ## Background diff --git a/astro.config.mjs b/astro.config.mjs index 3571d5f..5b6638d 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.js', + path: './src/example_sw.js', customRoutes: [ // '/threads' ], diff --git a/example_sw.js b/src/example_sw.js similarity index 96% rename from example_sw.js rename to src/example_sw.js index 3202505..5f427c8 100644 --- a/example_sw.js +++ b/src/example_sw.js @@ -1,4 +1,4 @@ -import { log } from "./src/utils"; +import { log } from "./utils"; /** * Note: @ayco/astro-sw integration injects variables `__prefix`, `__version`, & `__assets` @@ -78,9 +78,7 @@ self.addEventListener('activate', (event) => { self.addEventListener('install', (event) => { console.log('installing...', event) event.waitUntil( - addResourcesToCache([ - ...(__assets ?? []) - ]) + addResourcesToCache(__assets ?? []) ); });