import path from 'path'; import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; import { VitePWA } from 'vite-plugin-pwa'; export default defineConfig(({ mode }) => { const env = loadEnv(mode, '.', ''); return { server: { port: 3000, host: '0.0.0.0', }, plugins: [ react(), VitePWA({ registerType: 'autoUpdate', injectRegister: 'auto', // Re-enable SW for installation criteria includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'], manifest: { name: 'FoodSnap.ai', short_name: 'FoodSnap', description: 'Nutricionista de Bolso com InteligĂȘncia Artificial', theme_color: '#059669', background_color: '#ffffff', display: 'standalone', orientation: 'portrait', icons: [ { src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' }, { src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' }, { src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'any maskable' } ] }, workbox: { // NetworkOnly strategy to prevent caching issues/lag but allow installation runtimeCaching: [{ urlPattern: ({ request }) => request.destination === 'document' || request.destination === 'script' || request.destination === 'style' || request.destination === 'image', handler: 'NetworkOnly', }], cleanupOutdatedCaches: true, skipWaiting: true, clientsClaim: true, } }) ], define: { 'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY), 'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY) }, resolve: { alias: { '@': path.resolve(__dirname, './src'), } } }; });