import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import tailwindcss from "@tailwindcss/vite"; import { VitePWA } from "vite-plugin-pwa"; import path from "node:path"; import { fileURLToPath } from "node:url"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); export default defineConfig({ root: path.resolve(__dirname, "client"), plugins: [ react(), tailwindcss(), VitePWA({ registerType: "autoUpdate", includeAssets: ["favicon.svg", "icon-192x192.svg", "icon-512x512.svg"], manifest: { name: "QueueMed", short_name: "QueueMed", description: "Salle d'attente virtuelle pour cabinets médicaux. Vos patients scannent un QR code et suivent leur tour en temps réel.", theme_color: "#10b981", background_color: "#f0fdf4", display: "standalone", orientation: "portrait", start_url: "/", scope: "/", lang: "fr", icons: [ { src: "/icon-192x192.svg", sizes: "192x192", type: "image/svg+xml", purpose: "any maskable", }, { src: "/icon-512x512.svg", sizes: "512x512", type: "image/svg+xml", purpose: "any maskable", }, ], }, workbox: { globPatterns: ["**/*.{js,css,html,svg,png,ico,woff2}"], navigateFallbackDenylist: [/^\/api/, /^\/socket\.io/, /^\/trpc/], runtimeCaching: [ { urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i, handler: "CacheFirst", options: { cacheName: "google-fonts-stylesheets", expiration: { maxEntries: 10, maxAgeSeconds: 60 * 60 * 24 * 365 }, }, }, { urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i, handler: "CacheFirst", options: { cacheName: "google-fonts-webfonts", expiration: { maxEntries: 30, maxAgeSeconds: 60 * 60 * 24 * 365 }, cacheableResponse: { statuses: [0, 200] }, }, }, { urlPattern: /\/api\/.*$/i, handler: "NetworkFirst", options: { cacheName: "api-cache", networkTimeoutSeconds: 5, expiration: { maxEntries: 50, maxAgeSeconds: 60 * 5 }, cacheableResponse: { statuses: [0, 200] }, }, }, { urlPattern: /\/trpc\/.*$/i, handler: "NetworkFirst", options: { cacheName: "trpc-cache", networkTimeoutSeconds: 5, expiration: { maxEntries: 50, maxAgeSeconds: 60 * 5 }, cacheableResponse: { statuses: [0, 200] }, }, }, ], }, devOptions: { enabled: false, }, }), ], resolve: { alias: { "@": path.resolve(__dirname, "client/src"), "@shared": path.resolve(__dirname, "shared"), }, }, server: { port: 5173, host: true, proxy: { "/api": { target: "http://localhost:5000", changeOrigin: true, }, "/socket.io": { target: "http://localhost:5000", changeOrigin: true, ws: true, }, }, }, build: { outDir: path.resolve(__dirname, "dist/client"), emptyOutDir: true, sourcemap: false, }, });