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