vite.config.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { tanstackRouter } from '@tanstack/router-plugin/vite'
  2. import react from '@vitejs/plugin-react'
  3. import tailwindcss from '@tailwindcss/vite'
  4. import { defineConfig, loadEnv } from 'vite'
  5. import { resolve } from 'path'
  6. export default defineConfig(({ mode }) => {
  7. const env = loadEnv(mode, process.cwd(), '')
  8. const apiUrl = env.VITE_API_URL
  9. return {
  10. plugins: [
  11. tailwindcss(),
  12. {
  13. ...tanstackRouter({
  14. target: 'react',
  15. routesDirectory: 'src/routes',
  16. generatedRouteTree: 'src/routeTree.gen.ts',
  17. // routeFileIgnorePrefix: '_',
  18. autoCodeSplitting: true,
  19. verboseFileRoutes: false,
  20. quoteStyle: 'double',
  21. semicolons: true
  22. }),
  23. enforce: 'pre'
  24. },
  25. react({
  26. babel: {
  27. plugins: ["babel-plugin-react-compiler"]
  28. }
  29. })
  30. ],
  31. resolve: {
  32. alias: {
  33. '@': resolve(__dirname, 'src')
  34. }
  35. },
  36. server: {
  37. open: true,
  38. proxy: {
  39. '/api': {
  40. target: apiUrl,
  41. changeOrigin: true,
  42. secure: false
  43. }
  44. }
  45. },
  46. preview: {
  47. open: false,
  48. host: '0.0.0.0',
  49. port: 5173
  50. },
  51. build: {
  52. rollupOptions: {
  53. output: {
  54. manualChunks: {
  55. 'vendor-react': ['react', 'react-dom', 'react-dom/client'],
  56. 'vendor-xyflow': ['@xyflow/react', '@xyflow/system'],
  57. 'vendor-pixi': ['pixi.js'],
  58. 'vendor-monaco': ['@monaco-editor/react'],
  59. 'vendor-tiptap': [
  60. '@tiptap/react',
  61. '@tiptap/starter-kit',
  62. '@tiptap/core',
  63. ],
  64. 'vendor-map': ['maplibre-gl'],
  65. 'vendor-charts': ['recharts', 'd3', 'd3-force'],
  66. 'vendor-motion': ['framer-motion'],
  67. }
  68. }
  69. }
  70. }
  71. }
  72. })