Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,48 @@ import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const fromNodeModules = (...segments) => path.resolve(__dirname, 'node_modules', ...segments);

export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
react: path.resolve(__dirname, 'node_modules/react'),
'react-dom': path.resolve(__dirname, 'node_modules/react-dom')
},
dedupe: ['react', 'react-dom']
alias: [
// Keep every React entrypoint on the same physical package. This prevents
// Vite's dependency optimizer from serving mixed React instances after it
// discovers new deps during development, which causes "Invalid hook call".
{ find: /^react$/, replacement: fromNodeModules('react', 'index.js') },
{ find: /^react\/jsx-runtime$/, replacement: fromNodeModules('react', 'jsx-runtime.js') },
{ find: /^react\/jsx-dev-runtime$/, replacement: fromNodeModules('react', 'jsx-dev-runtime.js') },
{ find: /^react-dom$/, replacement: fromNodeModules('react-dom', 'index.js') },
{ find: /^react-dom\/client$/, replacement: fromNodeModules('react-dom', 'client.js') }
],
dedupe: [
'react',
'react/jsx-runtime',
'react/jsx-dev-runtime',
'react-dom',
'react-dom/client',
'react-router',
'react-router-dom'
]
},
optimizeDeps: {
entries: ['index.html', 'src/**/*.{js,jsx,ts,tsx}'],
include: [
'axios',
'i18next',
'leaflet',
'lucide-react',
'react',
'react/jsx-runtime',
'react/jsx-dev-runtime',
'react-dom',
'react-dom/client',
'react-i18next',
'react-leaflet',
'react-router-dom',
'socket.io-client'
]
},
server: {
port: 5173,
Expand Down
Loading