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 runtimeCaching: [
10 {
11 urlPattern: () => true,
12 handler: "NetworkOnly",
13 },
14 ],
15 },
16 manifest: {
17 name: "Pico Pixel Player",
18 short_name: "Pico Pixel Player",
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 //Some store frontends require this
63 src: "/assets/favicon-512x512.png",
64 sizes: "512x512",
65 type: "image/png",
66 purpose: "any",
67 },
68 ],
69 display: "standalone",
70 display_override: ["standalone", "minimal-ui", "fullscreen"],
71 },
72};
73
74export const hashPlugin = {
75 name: "pre-build-step",
76 buildStart() {
77 console.log("Running pre-build step...");
78 try {
79 execSync('echo "Running pre-build script" && sh src/generate-build-hash.sh', { stdio: "inherit" });
80 } catch (error) {
81 console.error("Pre-build step failed:", error);
82 process.exit(1);
83 }
84 },
85};
86