45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
build: {
|
|
// Generate source maps for production debugging
|
|
sourcemap: false,
|
|
// Optimize chunk size threshold
|
|
chunkSizeWarningLimit: 1000,
|
|
// Enable minification (use default for rolldown)
|
|
minify: true,
|
|
// Rollup options for advanced bundling
|
|
rollupOptions: {
|
|
output: {
|
|
// Manual chunk splitting for better caching
|
|
manualChunks: (id) => {
|
|
if (id.includes('react') || id.includes('react-dom')) {
|
|
return 'react'
|
|
}
|
|
if (id.includes('nanostores')) {
|
|
return 'stores'
|
|
}
|
|
if (id.includes('jszip') || id.includes('geopattern')) {
|
|
return 'vendor'
|
|
}
|
|
},
|
|
// Optimize chunk file names
|
|
chunkFileNames: 'assets/[name]-[hash].js',
|
|
entryFileNames: 'assets/[name]-[hash].js',
|
|
assetFileNames: 'assets/[name]-[hash].[ext]',
|
|
},
|
|
},
|
|
// Target modern browsers for better optimization
|
|
target: 'esnext',
|
|
// Enable CSS code splitting
|
|
cssCodeSplit: true,
|
|
},
|
|
// Optimize dependency pre-bundling
|
|
optimizeDeps: {
|
|
include: ['react', 'react-dom', 'nanostores', '@nanostores/react'],
|
|
},
|
|
})
|