-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
142 lines (141 loc) · 4.51 KB
/
vite.config.ts
File metadata and controls
142 lines (141 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { componentTagger } from "lovable-tagger";
import { VitePWA } from "vite-plugin-pwa";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
server: {
host: "::",
port: 8080,
hmr: {
overlay: false,
},
},
plugins: [
react(),
mode === "development" && componentTagger(),
VitePWA({
registerType: "autoUpdate",
includeAssets: ["favicon.png", "favicon.ico", "og-image.jpg", "hero-bg.jpg"],
manifest: {
name: "TryRamadan.app",
short_name: "TryRamadan",
description: "Fast like a Muslim for the holy month of Ramadan. Prayer times, suhoor & iftar, cultural education, progressive fasting.",
theme_color: "#1a3d2e",
background_color: "#f8f6f1",
display: "standalone",
orientation: "portrait",
scope: "/",
start_url: "/",
icons: [
{
src: "/favicon.png",
sizes: "192x192",
type: "image/png",
purpose: "any maskable"
},
{
src: "/favicon.png",
sizes: "512x512",
type: "image/png",
purpose: "any maskable"
}
],
categories: ["health", "lifestyle", "education"],
shortcuts: [
{
name: "Fasting Timer",
short_name: "Timer",
description: "Check your fasting countdown",
url: "/#programs",
icons: [{ src: "/favicon.png", sizes: "192x192" }]
}
]
},
workbox: {
globPatterns: ["**/*.{js,css,html,ico,png,svg,jpg,jpeg,webp,woff,woff2}"],
globIgnores: ["**/favicon.svg"],
cleanupOutdatedCaches: true,
runtimeCaching: [
{
urlPattern: /^https:\/\/api\.aladhan\.com\/.*/i,
handler: "NetworkFirst",
options: {
cacheName: "prayer-times-cache",
networkTimeoutSeconds: 10,
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24, // 24 hours
},
cacheableResponse: {
statuses: [200],
},
},
},
// Google Fonts: do not cache via SW — CacheFirst with empty cache can throw "no-response"
// when the request fails (e.g. adblocker, CORS), breaking page load. Let browser handle fonts.
{
urlPattern: /^https:\/\/nominatim\.openstreetmap\.org\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "nominatim-cache",
expiration: { maxEntries: 30, maxAgeSeconds: 60 * 60 * 24 }, // 24h
cacheableResponse: { statuses: [200] },
},
},
{
urlPattern: /^https:\/\/ipapi\.co\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "ipapi-cache",
expiration: { maxEntries: 5, maxAgeSeconds: 60 * 60 * 24 }, // 24h
cacheableResponse: { statuses: [200] },
},
},
{
urlPattern: /^https:\/\/timeapi\.io\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "timeapi-cache",
expiration: { maxEntries: 20, maxAgeSeconds: 60 * 60 * 24 * 7 }, // 7 days
cacheableResponse: { statuses: [200] },
},
},
{
urlPattern: /^https:\/\/api\.quran\.com\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "api-quran-cache",
expiration: { maxEntries: 50, maxAgeSeconds: 60 * 60 * 24 * 7 }, // 7 days
cacheableResponse: { statuses: [200] },
},
},
],
},
}),
].filter(Boolean),
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
sourcemap: mode === "development",
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes("node_modules")) {
if (id.includes("framer-motion")) return "motion";
if (id.includes("recharts")) return "recharts";
if (id.includes("lucide-react")) return "icons";
}
},
chunkFileNames: "assets/[name]-[hash].js",
entryFileNames: "assets/[name]-[hash].js",
assetFileNames: "assets/[name]-[hash][extname]",
},
},
chunkSizeWarningLimit: 600,
},
}));