Fetch preload files with 6 workers in flight instead of one-at-a-time, preserving retry/404/circuit-breaker/IDB-write-failure semantics. Browsers already cap ~6 connections per origin, so this is safe and cuts a full 3431-file preload to roughly 1/5 the wall-clock time. Remove the StaleWhileRevalidate routes for /data/*.json and /data/*.text. IndexedDB is the canonical offline store (every data read falls back to it), so the SW data caches only thrashed (200 entries over 3431 files) and added a caches.match/cache.put to every request. Keep NetworkFirst for the manifest and CacheFirst for fonts.
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import { resolve } from 'path';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
tailwindcss(),
|
|
VitePWA({ registerType: 'prompt',
|
|
workbox: {
|
|
skipWaiting: false,
|
|
clientsClaim: false,
|
|
globPatterns: ['**/*.{js,css,html,woff,png}'],
|
|
globIgnores: ['**/data/**'],
|
|
maximumFileSizeToCacheInBytes: 20 * 1024 * 1024,
|
|
runtimeCaching: [
|
|
{
|
|
// The preload file list must be fresh when online; a stale copy
|
|
// silently loses coverage. Offline falls back to the SW copy.
|
|
urlPattern: /\/data\/shared\/preload-manifest\.json$/,
|
|
handler: 'NetworkFirst',
|
|
options: {
|
|
cacheName: 'ponomar-manifest',
|
|
networkTimeoutSeconds: 3,
|
|
},
|
|
},
|
|
{
|
|
urlPattern: /\/fonts\/.*\.woff2?$/,
|
|
handler: 'CacheFirst',
|
|
options: {
|
|
cacheName: 'ponomar-fonts',
|
|
expiration: { maxEntries: 10, maxAgeSeconds: 60 * 60 * 24 * 365 },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
manifest: {
|
|
id: '/',
|
|
name: 'Ponomar — Orthodox Calendar',
|
|
short_name: 'Ponomar',
|
|
description: 'Orthodox Church calendar and liturgical information',
|
|
start_url: '/',
|
|
display: 'standalone',
|
|
background_color: '#f5f0e8',
|
|
theme_color: '#1a1a2e',
|
|
orientation: 'portrait',
|
|
icons: [
|
|
{ src: '/icons/icon-192.png', sizes: '192x192', type: 'image/png', purpose: 'any maskable' },
|
|
{ src: '/icons/icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any maskable' },
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
server: {
|
|
port: 5173,
|
|
strictPort: false,
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
sourcemap: true,
|
|
},
|
|
define: {
|
|
__BUILD_DATE__: JSON.stringify(new Date().toISOString().slice(0, 10)),
|
|
},
|
|
publicDir: 'static',
|
|
}); |