- Configure Vite to split vendor chunks (React, DOMPurify, video libs, Supabase) - Add manual chunk configuration to prevent duplicate module bundling - Clean Docker build cache and node_modules cache during build - Update Dockerfile to force clean rebuilds This should resolve the 'Identifier already declared' error in production caused by DOMPurify's @xmldom dependency being bundled multiple times. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react-swc";
|
|
import path from "path";
|
|
import { componentTagger } from "lovable-tagger";
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode }) => ({
|
|
server: {
|
|
host: "::",
|
|
port: 8080,
|
|
},
|
|
plugins: [react(), mode === "development" && componentTagger()].filter(Boolean),
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
build: {
|
|
// Disable minification completely to avoid variable conflicts
|
|
minify: false,
|
|
// Prevent duplicate bundling of dependencies
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: (id) => {
|
|
// Vendor chunks for better caching and deduplication
|
|
if (id.includes('node_modules')) {
|
|
// Group DOMPurify and its dependencies separately
|
|
if (id.includes('dompurify') || id.includes('@xmldom')) {
|
|
return 'vendor-dompurify';
|
|
}
|
|
// Group React separately
|
|
if (id.includes('react') || id.includes('react-dom') || id.includes('react-router')) {
|
|
return 'vendor-react';
|
|
}
|
|
// Group video libraries
|
|
if (id.includes('video.js') || id.includes('hls.js') || id.includes('plyr')) {
|
|
return 'vendor-video';
|
|
}
|
|
// Group Supabase
|
|
if (id.includes('@supabase')) {
|
|
return 'vendor-supabase';
|
|
}
|
|
// All other node_modules
|
|
return 'vendor';
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}));
|