import { execSync } from "node:child_process"; import type { VitePWAOptions } from "vite-plugin-pwa"; export const pwaOptions: Partial = { registerType: "autoUpdate", workbox: { globPatterns: ["**/*.{js,css,html,woff2}"], navigateFallback: undefined, runtimeCaching: [ { urlPattern: () => true, handler: "NetworkOnly", }, ], }, manifest: { id: "/", start_url: "/", scope: "/", name: "Pico Pixel Player", short_name: "Pico Pixel Player", description: "A directory based audio 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"], }, }; export const hashPlugin = { name: "pre-build-step", buildStart() { console.log("Running pre-build step..."); try { execSync('echo "Running pre-build script" && sh src/generate-build-hash.sh', { stdio: "inherit" }); } catch (error) { console.error("Pre-build step failed:", error); process.exit(1); } }, };