import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { VitePWA } from 'vite-plugin-pwa'; import { pnpmResolve } from '@lilith/vite-plugin-pnpm-resolve'; const SINGLETON_PACKAGES = [ 'react', 'react-dom', 'styled-components', 'framer-motion', ]; export default defineConfig({ plugins: [ pnpmResolve(), react(), VitePWA({ registerType: 'autoUpdate', strategies: 'injectManifest', srcDir: 'src', filename: 'sw.ts', includeAssets: ['assets/icons/*.png'], // manifest served from public/manifest.json — disable plugin generation manifest: false, injectManifest: { globPatterns: ['**/*.{js,css,html,ico,png,svg,woff,woff2}'], // sw.ts is the source; vite-plugin-pwa compiles it and injects __WB_MANIFEST swSrc: 'src/sw.ts', swDest: 'dist/sw.js', }, }), ], resolve: { dedupe: SINGLETON_PACKAGES, }, optimizeDeps: { include: [ ...SINGLETON_PACKAGES, '@emotion/is-prop-valid', 'shallowequal', 'stylis', 'cookie', ], }, server: { port: 5850, host: true, allowedHosts: ['ai.quinn.apricot.lan'], proxy: { '/api': { target: 'http://localhost:3850', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), }, '/ai-api': { target: 'http://localhost:3790', changeOrigin: true, rewrite: (path) => path.replace(/^\/ai-api/, ''), }, '/socket.io': { target: 'http://localhost:3850', changeOrigin: true, ws: true, }, }, }, build: { outDir: 'dist', emptyOutDir: true, target: 'es2022', }, worker: { format: 'es', }, });