-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43bcf74
commit 05f1fb0
Showing
1 changed file
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import { defaultCache } from "@serwist/next/browser"; | ||
import type { PrecacheEntry } from "@serwist/precaching"; | ||
import { installSerwist } from "@serwist/sw"; | ||
import { defaultCache } from "@serwist/next/worker"; | ||
import type { PrecacheEntry, SerwistGlobalConfig } from "serwist"; | ||
import { Serwist } from "serwist"; | ||
|
||
declare const self: ServiceWorkerGlobalScope & { | ||
// Change this attribute's name to your `injectionPoint`. | ||
// `injectionPoint` is an InjectManifest option. | ||
// See https://serwist.pages.dev/docs/build/inject-manifest/configuring | ||
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined; | ||
}; | ||
// This declares the value of `injectionPoint` to TypeScript. | ||
// `injectionPoint` is the string that will be replaced by the | ||
// actual precache manifest. By default, this string is set to | ||
// `"self.__SW_MANIFEST"`. | ||
declare global { | ||
interface WorkerGlobalScope extends SerwistGlobalConfig { | ||
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined; | ||
} | ||
} | ||
|
||
installSerwist({ | ||
declare const self: ServiceWorkerGlobalScope; | ||
|
||
const serwist = new Serwist({ | ||
precacheEntries: self.__SW_MANIFEST, | ||
skipWaiting: true, | ||
clientsClaim: true, | ||
navigationPreload: true, | ||
runtimeCaching: defaultCache, | ||
}); | ||
|
||
serwist.addEventListeners(); |