fix: service worker registration
This commit is contained in:
@@ -2,16 +2,28 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
|
||||
// A revision that changes on every build, so the SW always re-fetches index.html
|
||||
// when the app is redeployed. index.html is not picked up by globPatterns because
|
||||
// the static adapter creates it AFTER the service worker precache manifest is
|
||||
// generated — so we add it explicitly here instead.
|
||||
const buildId = Date.now().toString();
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
sveltekit(),
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
strategies: 'generateSW',
|
||||
injectRegister: 'auto',
|
||||
injectRegister: false,
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,svg,png,ico,woff,woff2}'],
|
||||
navigateFallback: 'index.html',
|
||||
globPatterns: ['**/*.{js,css,svg,png,ico,woff,woff2}'],
|
||||
additionalManifestEntries: [
|
||||
{ url: '/', revision: buildId },
|
||||
{ url: '/index.html', revision: buildId }
|
||||
],
|
||||
cleanupOutdatedCaches: true,
|
||||
clientsClaim: true,
|
||||
navigateFallback: '/index.html',
|
||||
navigateFallbackDenylist: [/^\/api/, /^\/healthz/],
|
||||
runtimeCaching: [
|
||||
{
|
||||
@@ -25,6 +37,10 @@ export default defineConfig({
|
||||
}
|
||||
]
|
||||
},
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
type: 'module'
|
||||
},
|
||||
manifest: {
|
||||
name: 'Wotra — Working Time Tracker',
|
||||
short_name: 'Wotra',
|
||||
|
||||
Reference in New Issue
Block a user