← Back
import { defineConfig } from 'vite'
import { fileURLToPath } from 'node:url'
import react from '@vitejs/plugin-react'
import { VitePWA } from 'vite-plugin-pwa'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    react(),
    VitePWA({
      registerType: 'autoUpdate',
      workbox: {
        globPatterns: ['**/*.{js,css,html,svg,png,woff2}'],
        // Privy + ethers + Polymarket SDKs push the main chunk past the default
        // 2 MiB precache limit; raise it so the SW build doesn't fail.
        maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
        // Activate a new build immediately instead of waiting for all tabs to close
        // (otherwise the PWA serves a stale app shell after deploys).
        skipWaiting: true,
        clientsClaim: true,
        cleanupOutdatedCaches: true,
        runtimeCaching: [
          {
            // Cache API responses (network-first, 5 min)
            urlPattern: /^\/api\//,
            handler: 'NetworkFirst',
            options: {
              cacheName: 'api-cache',
              expiration: { maxEntries: 50, maxAgeSeconds: 300 },
            },
          },
          {
            // Cache Google Fonts
            urlPattern: /^https:\/\/fonts\.(googleapis|gstatic)\.com/,
            handler: 'CacheFirst',
            options: {
              cacheName: 'google-fonts',
              expiration: { maxEntries: 10, maxAgeSeconds: 60 * 60 * 24 * 365 },
            },
          },
        ],
      },
      manifest: false, // use public/manifest.webmanifest directly
    }),
  ],
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://localhost:3240',
        changeOrigin: true
      }
    }
  },
  resolve: {
    alias: {
      // viem/wagmi may need this in some bundler setups
      buffer: 'buffer/',
      // Privy optionally imports getTransferSolInstruction from @solana-program/
      // system (Solana funding, unused). The real pkg pulls @solana/kit which is
      // unresolvable in the browser → black screen. Stub it (Ethereum-only).
      '@solana-program/system': fileURLToPath(new URL('./src/stubs/solana-system.ts', import.meta.url)),
    }
  },
  define: {
    global: 'globalThis',
  }
})

📜 Git History

6c47fa4chore: local Polikopi project home + Phase 1 redesign artifacts12 days ago
Show last diff
Loading...