import tailwindcss from '@tailwindcss/vite'; import react from '@vitejs/plugin-react'; import path from 'path'; import {defineConfig, loadEnv} from 'vite'; import { VitePWA } from 'vite-plugin-pwa'; export default defineConfig(({mode}) => { const env = loadEnv(mode, '.', ''); return { plugins: [ react(), tailwindcss(), VitePWA({ registerType: 'autoUpdate', manifest: { name: 'InstaArchive', short_name: 'InstaArchive', description: 'Browse your archived Instagram data with a native-feeling interface.', theme_color: '#ffffff', background_color: '#ffffff', display: 'standalone', icons: [ { src: 'https://cdn-icons-png.flaticon.com/512/174/174855.png', sizes: '512x512', type: 'image/png', purpose: 'any maskable' }, { src: 'https://cdn-icons-png.flaticon.com/192/174/174855.png', sizes: '192x192', type: 'image/png' } ] }, workbox: { navigateFallbackDenylist: [/^\/api/, /^\/archives/], globPatterns: ['**/*.{js,css,html,ico,png,svg,woff,woff2}'], runtimeCaching: [ { urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i, handler: 'CacheFirst', options: { cacheName: 'google-fonts-cache', expiration: { maxEntries: 10, maxAgeSeconds: 60 * 60 * 24 * 365 }, cacheableResponse: { statuses: [0, 200] } } } ] } }) ], define: { 'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY), }, resolve: { alias: { '@': path.resolve(__dirname, '.'), }, }, server: { // HMR is disabled in AI Studio via DISABLE_HMR env var. // Do not modify—file watching is disabled to prevent flickering during agent edits. hmr: process.env.DISABLE_HMR !== 'true', proxy: { '/api': 'http://localhost:3001', '/archives': 'http://localhost:3001', }, }, }; });