Files
SaaS-PDF/frontend/vite.config.ts
Your Name 7928e688d5 perf: optimize frontend bundle - reduce main chunk 77%
- vite.config: separate lucide-react icons + analytics into own chunks
- App.tsx: defer SiteAssistant loading via requestIdleCallback
- HeroUploadZone: lazy-load ToolSelectorModal + dynamic import fileRouting
- HeroUploadZone: add aria-label on dropzone input (accessibility)
- SocialProofStrip: defer API call until component is in viewport
- index.html: remove dev-only modulepreload hint

Main bundle: 266KB -> 61KB (-77%)
2026-04-04 22:36:45 +02:00

105 lines
2.2 KiB
TypeScript

/// <reference types="vitest/config" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
function getAllowedHosts() {
const defaultHosts = ['dociva.io', 'www.dociva.io', 'localhost', '127.0.0.1'];
const siteDomain = process.env.VITE_SITE_DOMAIN;
if (!siteDomain) {
return defaultHosts;
}
try {
const hostname = new URL(siteDomain).hostname;
return Array.from(new Set([...defaultHosts, hostname]));
} catch {
return defaultHosts;
}
}
export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/test/setup.ts'],
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 5173,
host: true,
allowedHosts: getAllowedHosts(),
proxy: {
'/api': {
target: 'http://backend:5000',
changeOrigin: true,
},
},
},
preview: {
host: true,
allowedHosts: getAllowedHosts(),
},
build: {
outDir: 'dist',
sourcemap: false,
cssMinify: true,
target: 'es2020',
chunkSizeWarningLimit: 600,
minify: 'esbuild',
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) {
return undefined;
}
if (id.includes('react-dom') || id.includes('/react/')) {
return 'vendor';
}
if (id.includes('react-router-dom')) {
return 'router';
}
if (id.includes('i18next') || id.includes('react-i18next')) {
return 'i18n';
}
if (id.includes('react-helmet-async')) {
return 'helmet';
}
if (id.includes('/axios/')) {
return 'network';
}
if (id.includes('/pdf-lib/')) {
return 'pdf-core';
}
if (id.includes('/fabric/')) {
return 'editor';
}
if (id.includes('lucide-react')) {
return 'icons';
}
if (id.includes('@microsoft/clarity')) {
return 'analytics';
}
return undefined;
},
},
},
},
});