import react from '@vitejs/plugin-react'; import { defineConfig } from 'vite'; import { VitePWA } from 'vite-plugin-pwa'; import { visualizer } from 'rollup-plugin-visualizer'; // `npm run build:analyze` writes dist/stats.html — a treemap of what actually ended // up in each chunk. The plain build only reports chunk sizes, which tells you a chunk // is too big but not which dependency made it so. export default defineConfig(({ mode }) => ({ plugins: [ react(), mode === 'analyze' && visualizer({ filename: 'dist/stats.html', gzipSize: true, brotliSize: true }), VitePWA({ registerType: 'autoUpdate', // Serve the generated manifest (+ dev SW) in development too, so the installed // PWA can be tested against the dev server. Without this, dev ships no // , so iOS falls back to legacy standalone // (apple-mobile-web-app-capable only) and pops the Safari chrome on every // in-app navigation away from the start URL. Prod already serves the manifest. devOptions: { enabled: true, type: 'module', suppressWarnings: true, /* * No navigation fallback from the dev service worker. * * `workbox.navigateFallback` below is right for production: offline, a * deep link has to be answered by the cached shell. In development it * means the worker answers a reload with the index.html it cached * earlier, whose