service worker

This commit is contained in:
vabene1111
2025-07-29 16:57:51 +02:00
parent 92578dd6a2
commit c2e522d9f2
10 changed files with 43 additions and 56 deletions

View File

@@ -36,6 +36,7 @@
"typescript": "^5.8.3",
"vite": "6.3.5",
"vite-plugin-pwa": "^1.0.1",
"workbox-core": "^7.3.0",
"workbox-build": "^7.3.0",
"workbox-window": "^7.3.0",
"workbox-background-sync": "^7.3.0",

View File

@@ -4,12 +4,18 @@ import {registerRoute, setCatchHandler} from 'workbox-routing';
import {CacheFirst, NetworkFirst, NetworkOnly, StaleWhileRevalidate} from 'workbox-strategies';
import {ExpirationPlugin} from 'workbox-expiration';
import {BackgroundSyncPlugin, Queue} from "workbox-background-sync";
import { clientsClaim } from 'workbox-core'
cleanupOutdatedCaches()
declare let self: ServiceWorkerGlobalScope
precacheAndRoute(self.__WB_MANIFEST)
self.skipWaiting()
clientsClaim()
const OFFLINE_CACHE_NAME = 'offline-html';
let script_name = typeof window !== 'undefined' ? localStorage.getItem('SCRIPT_NAME') : '/'
var OFFLINE_PAGE_URL = script_name + 'offline/';

View File

@@ -16,14 +16,10 @@ export default defineConfig({
autoImport: true,
}),
VitePWA({
registerType: 'autoUpdate',
//registerType: 'autoUpdate',
strategies: 'injectManifest',
srcDir: 'src',
filename: 'service-worker.ts',
injectManifest: {
swDest: "../cookbook/templates/sw.js",
injectionPoint: undefined
}
})
],
resolve: {

View File

@@ -3581,7 +3581,7 @@ workbox-cacheable-response@7.3.0:
dependencies:
workbox-core "7.3.0"
workbox-core@7.3.0:
workbox-core@7.3.0, workbox-core@^7.3.0:
version "7.3.0"
resolved "https://registry.yarnpkg.com/workbox-core/-/workbox-core-7.3.0.tgz#f24fb92041a0b7482fe2dd856544aaa9fa105248"
integrity sha512-Z+mYrErfh4t3zi7NVTvOuACB0A/jA3bgxUN3PwtAVHvfEsZxV9Iju580VEETug3zYJRc0Dmii/aixI/Uxj8fmw==