vite.common.config.ts
| 1 | import { execSync } from "node:child_process"; |
| 2 | import type { VitePWAOptions } from "vite-plugin-pwa"; |
| 3 | |
| 4 | export const pwaOptions: Partial<VitePWAOptions> = { |
| 5 | registerType: "autoUpdate", |
| 6 | workbox: { |
| 7 | globPatterns: ["**/*.{js,css,html,woff2}"], |
| 8 | navigateFallback: undefined, |
| 9 | runtimeCaching: [ |
| 10 | { |
| 11 | urlPattern: () => true, |
| 12 | handler: "NetworkOnly", |
| 13 | }, |
| 14 | ], |
| 15 | }, |
| 16 | manifest: { |
| 17 | id: "/", |
| 18 | start_url: "/", |
| 19 | scope: "/", |
| 20 | name: "Pico Pixel Player", |
| 21 | short_name: "Pico Pixel Player", |
| 22 | description: "A directory based audio player with offline functionality", |
| 23 | theme_color: "#3f4d4e", |
| 24 | screenshots: [ |
| 25 | { |
| 26 | src: "/assets/screenshot-narrow.png", |
| 27 | form_factor: "narrow", |
| 28 | sizes: "600x800", |
| 29 | }, |
| 30 | { |
| 31 | src: "/assets/screenshot-wide.png", |
| 32 | form_factor: "wide", |
| 33 | sizes: "1400x800", |
| 34 | }, |
| 35 | ], |
| 36 | background_color: "#3f4d4e", |
| 37 | icons: [ |
| 38 | { |
| 39 | src: "/assets/favicon-any.svg", |
| 40 | sizes: "any", |
| 41 | type: "image/svg+xml", |
| 42 | purpose: "any", |
| 43 | }, |
| 44 | { |
| 45 | src: "/assets/favicon-maskable.svg", |
| 46 | sizes: "any", |
| 47 | type: "image/svg+xml", |
| 48 | purpose: "maskable", |
| 49 | }, |
| 50 | { |
| 51 | //Android |
| 52 | src: "/assets/favicon-192x192.png", |
| 53 | sizes: "192x192", |
| 54 | type: "image/png", |
| 55 | purpose: "maskable", |
| 56 | }, |
| 57 | { |
| 58 | //iOS |
| 59 | src: "/assets/favicon-180x180.png", |
| 60 | sizes: "180x180", |
| 61 | type: "image/png", |
| 62 | purpose: "maskable", |
| 63 | }, |
| 64 | { |
| 65 | //Some store frontends require this |
| 66 | src: "/assets/favicon-512x512.png", |
| 67 | sizes: "512x512", |
| 68 | type: "image/png", |
| 69 | purpose: "any", |
| 70 | }, |
| 71 | ], |
| 72 | display: "standalone", |
| 73 | display_override: ["standalone", "minimal-ui", "fullscreen"], |
| 74 | }, |
| 75 | }; |
| 76 | |
| 77 | export const hashPlugin = { |
| 78 | name: "pre-build-step", |
| 79 | buildStart() { |
| 80 | console.log("Running pre-build step..."); |
| 81 | try { |
| 82 | execSync('echo "Running pre-build script" && sh src/generate-build-hash.sh', { stdio: "inherit" }); |
| 83 | } catch (error) { |
| 84 | console.error("Pre-build step failed:", error); |
| 85 | process.exit(1); |
| 86 | } |
| 87 | }, |
| 88 | }; |
| 89 |