chore: move example_sw.js to src

This commit is contained in:
Ayo Ayco 2024-08-17 21:18:30 +02:00
parent 574c14fb13
commit 13978f8380
3 changed files with 4 additions and 6 deletions

View file

@ -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

View file

@ -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'
],

View file

@ -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 ?? [])
);
});