64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
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}'],
|
|
cleanupOutdatedCaches: true,
|
|
runtimeCaching: [
|
|
{
|
|
// Network-first pour les listes (évite de servir un cache vide)
|
|
urlPattern: /^\/api\/(?:companies|categories)/,
|
|
handler: 'NetworkFirst',
|
|
options: {
|
|
cacheName: 'notesfrais-api-static',
|
|
networkTimeoutSeconds: 8,
|
|
expiration: { maxEntries: 20, maxAgeSeconds: 60 * 60 },
|
|
},
|
|
},
|
|
{
|
|
// Network-first pour les factures (données fraîches prioritaires)
|
|
urlPattern: /^\/api\/invoices/,
|
|
handler: 'NetworkFirst',
|
|
options: {
|
|
cacheName: 'notesfrais-api-invoices',
|
|
networkTimeoutSeconds: 8,
|
|
expiration: { maxEntries: 100, maxAgeSeconds: 24 * 60 * 60 },
|
|
},
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
server: {
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:3001',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
});
|