import { writeFileSync } from "node:fs"; import type { VitePWAOptions } from "vite-plugin-pwa"; export const pwaOptions: Partial = { registerType: "autoUpdate", workbox: { globPatterns: ["**/*.{js,css,html,woff2}"], navigateFallback: undefined, //Leave media requests outside Workbox so native Range requests and cancellation are handled directly. }, manifest: { id: "/", start_url: "/", scope: "/", name: "Pico Pixel Player", short_name: "Pico Pixel Player", description: "A directory based media player with offline functionality", theme_color: "#3f4d4e", screenshots: [ { src: "/assets/screenshot-narrow.png", form_factor: "narrow", sizes: "600x800", }, { src: "/assets/screenshot-wide.png", form_factor: "wide", sizes: "1400x800", }, ], background_color: "#3f4d4e", icons: [ { src: "/assets/favicon-any.svg", sizes: "any", type: "image/svg+xml", purpose: "any", }, { src: "/assets/favicon-maskable.svg", sizes: "any", type: "image/svg+xml", purpose: "maskable", }, { //Android src: "/assets/favicon-192x192.png", sizes: "192x192", type: "image/png", purpose: "maskable", }, { //iOS src: "/assets/favicon-180x180.png", sizes: "180x180", type: "image/png", purpose: "maskable", }, { //Some store frontends require this src: "/assets/favicon-512x512.png", sizes: "512x512", type: "image/png", purpose: "any", }, ], display: "standalone", display_override: ["standalone", "minimal-ui", "fullscreen"], }, }; //a fresh id per build, shown in the header so a running client can be matched to a deployment export const hashPlugin = { name: "build-hash", buildStart() { writeFileSync("src/build-info.ts", `export const BUILD_HASH = "${crypto.randomUUID().toUpperCase()}";\n`); }, };