vite.config.ts

 1import { defineConfig } from 'vite'
 2import react from '@vitejs/plugin-react'
 3import path from 'path'
 4
 5// The Go backend URL. Run: git-bug webui --port 3000
 6const API_URL = process.env.VITE_API_URL || 'http://localhost:3000'
 7
 8export default defineConfig({
 9  plugins: [react()],
10  resolve: {
11    alias: {
12      '@': path.resolve(__dirname, './src'),
13    },
14  },
15  build: {
16    // highlight.js is inherently large (~1MB) but lazy-loaded; silence the warning.
17    chunkSizeWarningLimit: 1100,
18    rollupOptions: {
19      output: {
20        manualChunks: {
21          'vendor-react': ['react', 'react-dom', 'react-router-dom'],
22          'vendor-apollo': ['@apollo/client', 'graphql'],
23          'vendor-markdown': ['react-markdown', 'remark-gfm'],
24          'vendor-highlight': ['highlight.js'],
25        },
26      },
27    },
28  },
29  server: {
30    proxy: {
31      '/graphql': { target: API_URL, changeOrigin: true },
32      '/gitfile': { target: API_URL, changeOrigin: true },
33      '/upload': { target: API_URL, changeOrigin: true },
34      '/api': { target: API_URL, changeOrigin: true },
35      '/auth': { target: API_URL, changeOrigin: true },
36    },
37  },
38})