import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { VitePWA } from 'vite-plugin-pwa'; export default defineConfig({ plugins: [ react(), VitePWA({ registerType: 'autoUpdate', includeAssets: ['favicon.svg', 'apple-touch-icon.png'], manifest: { name: 'NotesFrais', short_name: 'NotesFrais', description: 'Gestion de notes de frais professionnelles', theme_color: '#4f46e5', background_color: '#f9fafb', display: 'standalone', orientation: 'portrait', scope: '/', start_url: '/', icons: [ { src: 'pwa-192.png', sizes: '192x192', type: 'image/png' }, { src: 'pwa-512.png', sizes: '512x512', type: 'image/png' }, { src: 'pwa-512.png', sizes: '512x512', type: 'image/png', purpose: 'any maskable' }, ], }, workbox: { globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'], runtimeCaching: [ { // Cache API responses (stale-while-revalidate pour les listes) urlPattern: /^\/api\/(?:companies|categories)/, handler: 'StaleWhileRevalidate', options: { cacheName: 'api-static', expiration: { maxEntries: 20, maxAgeSeconds: 60 * 60 }, }, }, { // Network-first pour les factures (données fraîches prioritaires) urlPattern: /^\/api\/invoices/, handler: 'NetworkFirst', options: { cacheName: 'api-invoices', networkTimeoutSeconds: 8, expiration: { maxEntries: 100, maxAgeSeconds: 24 * 60 * 60 }, }, }, ], }, }), ], server: { proxy: { '/api': { target: 'http://localhost:3001', changeOrigin: true, }, }, }, });