-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
127 lines (126 loc) · 3.49 KB
/
Copy pathvite.config.ts
File metadata and controls
127 lines (126 loc) · 3.49 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { VitePWA } from "vite-plugin-pwa";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
server: {
host: "::",
port: 8080,
},
plugins: [
react(),
VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.svg', 'favicon.ico', 'apple-touch-icon.png'],
manifest: {
name: 'Gramin Saathi - Rural Digital Companion',
short_name: 'Gramin Saathi',
description: 'Digital financial assistant for rural India - works offline',
theme_color: '#0a1f1a',
background_color: '#0a1f1a',
display: 'standalone',
orientation: 'portrait',
start_url: '/',
scope: '/',
lang: 'hi',
icons: [
{
src: '/favicon.svg',
sizes: '192x192',
type: 'image/svg+xml',
purpose: 'any maskable'
},
{
src: '/favicon.svg',
sizes: '512x512',
type: 'image/svg+xml',
purpose: 'any maskable'
}
]
},
workbox: {
// Cache strategies for offline-first
runtimeCaching: [
{
// Cache Google Fonts
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365 // 1 year
}
}
},
{
// Cache API responses (Mandi, Weather)
urlPattern: /^https:\/\/api\.data\.gov\.in\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'mandi-api-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 // 1 hour
},
networkTimeoutSeconds: 10
}
},
{
// Cache OpenWeather API
urlPattern: /^https:\/\/api\.openweathermap\.org\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'weather-api-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 30 // 30 minutes
},
networkTimeoutSeconds: 10
}
},
{
// Cache images
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp)$/,
handler: 'CacheFirst',
options: {
cacheName: 'images-cache',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days
}
}
}
],
// Precache all static assets
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}']
},
devOptions: {
enabled: true // Enable PWA in development for testing
}
})
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
chunkSizeWarningLimit: 600,
rollupOptions: {
output: {
manualChunks: {
vendor: ["react", "react-dom", "react-router-dom"],
firebase: [
"firebase/app",
"firebase/auth",
"firebase/firestore",
"firebase/analytics",
],
ui: ["lucide-react", "recharts", "date-fns"],
},
},
},
},
}));