N-FIN-83: fix serwist configuration
This commit is contained in:
parent
5be1e78ddd
commit
59007f5973
1 changed files with 34 additions and 3 deletions
|
@ -1,15 +1,46 @@
|
|||
import { defaultCache } from '@serwist/next/browser';
|
||||
import type { PrecacheEntry } from '@serwist/precaching';
|
||||
import { installSerwist } from '@serwist/sw';
|
||||
import { defaultCache } from '@serwist/next/worker';
|
||||
import { Serwist, SerwistGlobalConfig } from 'serwist';
|
||||
|
||||
declare const self: ServiceWorkerGlobalScope & {
|
||||
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
|
||||
};
|
||||
|
||||
installSerwist({
|
||||
declare global {
|
||||
interface WorkerGlobalScope extends SerwistGlobalConfig {
|
||||
// Change this attribute's name to your \`injectionPoint\`.
|
||||
// \`injectionPoint\` is an InjectManifest option.
|
||||
// See https://serwist.pages.dev/docs/build/configuring
|
||||
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const serwist = new Serwist({
|
||||
// A list of URLs that should be cached. Usually, you don't generate
|
||||
// this list yourself; rather, you'd rely on a Serwist build tool/your framework
|
||||
// to do it for you. In this example, it is generated by \`@serwist/vite\`.
|
||||
precacheEntries: self.__SW_MANIFEST,
|
||||
// Options to customize how Serwist precaches the URLs.
|
||||
precacheOptions: {
|
||||
// Whether outdated caches should be removed.
|
||||
cleanupOutdatedCaches: true,
|
||||
concurrency: 10,
|
||||
ignoreURLParametersMatching: [],
|
||||
},
|
||||
// Whether the service worker should skip waiting and become the active one.
|
||||
skipWaiting: true,
|
||||
// Whether the service worker should claim any currently available clients.
|
||||
clientsClaim: true,
|
||||
// Whether navigation preloading should be used.
|
||||
navigationPreload: true,
|
||||
// Whether Serwist should log in development mode.
|
||||
disableDevLogs: true,
|
||||
// A list of runtime caching entries. When a request is made and its URL match
|
||||
// any of the entries, the response to it will be cached according to the matching
|
||||
// entry's \`handler\`. This does not apply to precached URLs.
|
||||
runtimeCaching: defaultCache,
|
||||
// Other options...
|
||||
// See https://serwist.pages.dev/docs/serwist/core/serwist
|
||||
});
|
||||
|
||||
serwist.addEventListeners();
|
||||
|
|
Loading…
Add table
Reference in a new issue