Merge remote-tracking branch 'origin/main' into 22-semi-offline-room-finder

This commit is contained in:
survellow
2024-09-23 23:12:58 +02:00
22 changed files with 495 additions and 188 deletions

View File

@@ -28,7 +28,13 @@ export default defineConfig({
mode: "development",
base: "/",
injectRegister: "auto",
includeAssets: ["favicon.ico", "apple-touch-icon.png", "mask-icon.svg"],
includeAssets: [
"favicon.ico",
"apple-touch-icon.png",
"mask-icon.svg",
"robots.txt",
"sitemap.xml",
],
manifest: {
name: "HTWKalender",
short_name: "HTWKalender",
@@ -81,55 +87,15 @@ export default defineConfig({
],
},
registerType: "autoUpdate",
workbox: {
strategies: "injectManifest",
injectManifest: {
globPatterns: ["**/*.{js,css,html,ico,png,svg,json,vue,txt,woff2}", "/api/schedule/rooms"],
cleanupOutdatedCaches: true,
runtimeCaching: [
{
urlPattern: ({ url }) => url.pathname.startsWith("/api/feed"),
method: "GET",
handler: "NetworkFirst",
options: {
cacheName: "calendar-feed-cache",
expiration: {
maxAgeSeconds: 12 * 60 * 60, // 12 hours
},
},
},
{
urlPattern: ("/api/schedule/rooms"),
method: "GET",
handler: "StaleWhileRevalidate",
options: {
cacheName: "room-schedule-cache",
expiration: {
maxAgeSeconds: 12 * 60 * 60, // 12 hours
},
},
},
{
urlPattern: /^https?.*/,
handler: "NetworkFirst",
options: {
cacheName: "https-calls",
expiration: {
maxEntries: 150,
maxAgeSeconds: 30 * 12 * 60 * 60, // 1 month
},
networkTimeoutSeconds: 10, // fall back to cache if api does not response within 10 seconds
},
},
],
},
devOptions: {
enabled: true,
/* when using generateSW the PWA plugin will switch to classic */
type: "module",
navigateFallback: "index.html",
suppressWarnings: true,
},
}),
],
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
@@ -149,6 +115,9 @@ export default defineConfig({
},
},
},
build: {
sourcemap: true,
},
esbuild: {
supported: {
"top-level-await": true,