-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
185 lines (183 loc) · 5.14 KB
/
vite.config.ts
File metadata and controls
185 lines (183 loc) · 5.14 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { VitePWA } from 'vite-plugin-pwa';
import { resolve } from 'path';
// GitHub Pages base path - set via environment variable or default to '/'
// For GitHub Pages: /SEC-GoogleAuthenticatorExportDecoder/
// For custom domain or Docker: /
const base = process.env.GITHUB_PAGES === 'true'
? '/SEC-GoogleAuthenticatorExportDecoder/'
: '/';
export default defineConfig({
base,
plugins: [
react(),
tailwindcss(),
VitePWA({
registerType: 'autoUpdate',
includeAssets: [
'icon-192x192.png',
'icon-512x512.png',
'locales/**/*.json'
],
manifest: {
name: 'Google Authenticator Export Decoder',
short_name: 'Auth Decoder',
description: 'Scan Google Authenticator export QR codes and export TOTP secrets to CSV, JSON, or Bitwarden format',
theme_color: '#4285f4',
background_color: '#ffffff',
display: 'standalone',
orientation: 'portrait-primary',
start_url: base,
scope: base,
id: base,
categories: ['utilities', 'security'],
lang: 'en',
dir: 'ltr',
icons: [
{
src: 'icon-192x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any'
},
{
src: 'icon-192x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'maskable'
},
{
src: 'icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any'
},
{
src: 'icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable'
}
]
},
workbox: {
// Precache all built assets
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff,woff2}'],
// Also precache translation files
globIgnores: ['**/node_modules/**'],
// Navigation fallback for SPA
navigateFallback: 'index.html',
navigateFallbackDenylist: [/^\/api\//],
// Clean old caches on update
cleanupOutdatedCaches: true,
// Client claims for immediate activation
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [
// Cache translation files with StaleWhileRevalidate
{
urlPattern: /\/locales\/.*\.json$/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'translations-cache',
expiration: {
maxEntries: 20,
maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days
},
cacheableResponse: {
statuses: [0, 200]
}
}
},
// Cache Google Fonts stylesheets
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'google-fonts-stylesheets',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365 // 1 year
},
cacheableResponse: {
statuses: [0, 200]
}
}
},
// Cache Google Fonts files
{
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-webfonts',
expiration: {
maxEntries: 30,
maxAgeSeconds: 60 * 60 * 24 * 365 // 1 year
},
cacheableResponse: {
statuses: [0, 200]
}
}
},
// Cache images
{
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp|ico)$/i,
handler: 'CacheFirst',
options: {
cacheName: 'images-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days
},
cacheableResponse: {
statuses: [0, 200]
}
}
}
]
},
// Development options for easier testing
devOptions: {
enabled: false, // Set to true to test PWA in development
type: 'module',
navigateFallback: 'index.html'
}
})
],
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
build: {
target: 'ES2020',
sourcemap: false,
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom'],
i18n: ['i18next', 'react-i18next', 'i18next-browser-languagedetector', 'i18next-http-backend'],
qrcode: ['html5-qrcode'],
protobuf: ['protobufjs']
}
}
}
},
server: {
port: 5173,
host: true
},
preview: {
port: 4173
},
test: {
// Exclude legacy template-project from tests
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/template-project/**'
]
}
});