63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import svgr from "vite-plugin-svgr";
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
const isDev = mode === "development";
|
|
|
|
return {
|
|
plugins: [
|
|
react(),
|
|
svgr({
|
|
svgrOptions: {
|
|
icon: true,
|
|
// This will transform your SVG to a React component
|
|
exportType: "named",
|
|
namedExport: "ReactComponent",
|
|
},
|
|
}),
|
|
],
|
|
// Optimize dependency pre-bundling
|
|
optimizeDeps: {
|
|
include: [
|
|
'react-apexcharts',
|
|
'apexcharts',
|
|
'clsx',
|
|
'tailwind-merge',
|
|
],
|
|
exclude: [], // Don't exclude anything
|
|
esbuildOptions: {
|
|
// Increase timeout for large dependencies
|
|
target: 'es2020',
|
|
},
|
|
},
|
|
// Only configure server and HMR in development mode
|
|
...(isDev && {
|
|
server: {
|
|
host: "0.0.0.0", // Allow external connections (for Docker)
|
|
port: 5173,
|
|
strictPort: false, // Allow port fallback if 5173 is busy
|
|
allowedHosts: [
|
|
"app.igny8.com",
|
|
"localhost",
|
|
"127.0.0.1",
|
|
],
|
|
watch: {
|
|
usePolling: true, // Needed for file watching in Docker
|
|
},
|
|
hmr: {
|
|
// Behind reverse proxy - use same origin strategy
|
|
// Client connects via public domain (app.igny8.com) on default HTTPS port (443)
|
|
// Caddy automatically proxies WebSocket upgrades from 443 to 5173
|
|
protocol: "wss",
|
|
// Don't specify host/port - Vite will use same origin as page
|
|
// This ensures client connects to wss://app.igny8.com (port 443 implicit)
|
|
},
|
|
// Increase timeout for slow connections and dependency pre-bundling
|
|
timeout: 120000, // 120 seconds (2 minutes) to match Caddy timeout
|
|
},
|
|
}),
|
|
};
|
|
});
|