import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; import { VitePWA } from 'vite-plugin-pwa'; import { fileURLToPath } from 'node:url'; const env = loadEnv('development', fileURLToPath(new URL('./', import.meta.url)), ''); const apiTarget = `http://127.0.0.1:${process.env.API_PORT ?? env.API_PORT ?? 3001}`; const proxy = { '/api': { target: apiTarget, rewrite: (path: string) => path.replace(/^\/api/, '') } }; export default defineConfig({ plugins: [react(), VitePWA({ registerType: 'prompt', includeAssets: ['favicon.ico', 'favicon-32.png', 'favicon-48.png', 'brand-logo.png', 'brand-logo.webp', 'icon-192.png', 'icon-512.png', 'icon-maskable-512.png', 'apple-touch-icon.png'], manifest: { name: 'מודל משלוחים', short_name: 'משלוחים', description: 'ניהול משלוחי מעבדת שיניים', lang: 'he', dir: 'rtl', theme_color: '#2D3845', background_color: '#f8f3ed', display: 'standalone', start_url: '/', scope: '/', icons: [{ src: '/icon-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' }, { src: '/icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any' }, { src: '/icon-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' }], }, workbox: { globPatterns: ['**/*.{js,css,html,png,webp,ico,woff2}'], navigateFallbackDenylist: [/^\/api(?:\/|$)/], cleanupOutdatedCaches: true }, devOptions: { enabled: false }, })], server: { port: 5173, strictPort: true, proxy }, preview: { port: 4173, strictPort: true, proxy }, });