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