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,wasm,css,html,woff2}"],
8 navigateFallback: undefined,
9 runtimeCaching: [
10 {
11 urlPattern: () => true,
12 handler: "NetworkOnly",
13 },
14 ],
15 },
16 manifest: {
17 name: "Pico Pixel Player",
18 short_name: undefined,
19 description: "A directory based audio player with offline functionality",
20 theme_color: "#3f4d4e",
21 screenshots: [
22 {
23 src: "/assets/screenshot-narrow.png",
24 form_factor: "narrow",
25 sizes: "600x800",
26 },
27 {
28 src: "/assets/screenshot-wide.png",
29 form_factor: "wide",
30 sizes: "1400x800",
31 },
32 ],
33 background_color: "#3f4d4e",
34 icons: [
35 {
36 src: "/assets/favicon-any.svg",
37 sizes: "any",
38 type: "image/svg+xml",
39 purpose: "any",
40 },
41 {
42 src: "/assets/favicon-maskable.svg",
43 sizes: "any",
44 type: "image/svg+xml",
45 purpose: "maskable",
46 },
47 {
48 //Android
49 src: "/assets/favicon-192x192.png",
50 sizes: "192x192",
51 type: "image/png",
52 purpose: "maskable",
53 },
54 {
55 //iOS
56 src: "/assets/favicon-180x180.png",
57 sizes: "180x180",
58 type: "image/png",
59 purpose: "maskable",
60 },
61 ],
62 display: "standalone",
63 display_override: ["standalone", "minimal-ui", "fullscreen"],
64 },
65};
66
67export const hashPlugin = {
68 name: "pre-build-step",
69 buildStart() {
70 console.log("Running pre-build step...");
71 try {
72 execSync('echo "Running pre-build script" && sh src/generate-build-hash.sh', { stdio: "inherit" });
73 } catch (error) {
74 console.error("Pre-build step failed:", error);
75 process.exit(1);
76 }
77 },
78};
79