FMHYedit/.vitepress/pwa.ts

103 lines
2.4 KiB
TypeScript
Raw Normal View History

2023-10-30 18:32:25 +00:00
import type { PwaOptions } from "@vite-pwa/vitepress";
2023-10-30 18:38:03 +00:00
import { meta } from "./constants";
2023-10-30 19:33:37 +00:00
import { resolve } from "pathe";
import fg from "fast-glob";
2023-10-30 18:32:25 +00:00
export const pwa = {
outDir: ".vitepress/dist",
registerType: "autoUpdate",
includeManifestIcons: false,
2023-10-30 19:33:37 +00:00
includeAssets: fg.sync("**/*.{png,webp,svg,gif,ico,txt}", {
cwd: resolve(__dirname, "../public"),
}),
2023-10-30 18:32:25 +00:00
manifest: {
id: "/",
2023-10-30 18:38:03 +00:00
name: meta.name,
short_name: meta.name,
description: meta.description,
2023-10-30 18:32:25 +00:00
theme_color: "#ffffff",
start_url: "/",
lang: "en-US",
dir: "ltr",
orientation: "natural",
display: "standalone",
display_override: ["window-controls-overlay"],
2023-10-30 18:38:03 +00:00
categories: meta.keywords,
2023-10-30 19:33:37 +00:00
// TODO: replace with actual icons
2023-10-30 18:32:25 +00:00
icons: [
{
2023-10-30 19:33:37 +00:00
src: "test.png",
2023-10-30 18:32:25 +00:00
sizes: "64x64",
type: "image/png",
},
{
2023-10-30 19:33:37 +00:00
src: "test.png",
2023-10-30 18:32:25 +00:00
sizes: "192x192",
type: "image/png",
},
{
2023-10-30 19:33:37 +00:00
src: "test.png",
2023-10-30 18:32:25 +00:00
sizes: "512x512",
type: "image/png",
purpose: "any",
},
{
src: "maskable-icon.png",
sizes: "512x512",
type: "image/png",
purpose: "maskable",
},
],
handle_links: "preferred",
launch_handler: {
client_mode: ["navigate-existing", "auto"],
},
edge_side_panel: {
preferred_width: 480,
},
},
experimental: {
includeAllowlist: true,
},
workbox: {
globPatterns: ["**/*.{css,js,html,svg,png,ico,txt,woff2,json}"],
2023-10-30 19:33:37 +00:00
globIgnores: ["**/404.html"],
navigateFallback: null,
2023-10-30 18:32:25 +00:00
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "google-fonts-cache",
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "gstatic-fonts-cache",
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
2023-10-30 19:33:37 +00:00
devOptions: {
enabled: true,
suppressWarnings: false,
},
2023-10-30 18:32:25 +00:00
} satisfies PwaOptions;