85 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			85 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { defineConfig, type UserConfigExport } from "vite";
 | |
| import react from "@vitejs/plugin-react";
 | |
| import tailwindcss from "@tailwindcss/vite";
 | |
| import path from "path";
 | |
| 
 | |
| type ManualChunksFn = (id: string, api: { getModuleIds: () => Iterable<string> }) => string | undefined;
 | |
| 
 | |
| const manualChunks: ManualChunksFn = (id) => {
 | |
|   if (id.includes('node_modules')) {
 | |
|     
 | |
|     if (
 | |
|         id.includes('three.') || 
 | |
|         id.includes('@react-three') ||
 | |
|         id.includes('ol/') || 
 | |
|         id.includes('mapbox-gl') || 
 | |
|         id.includes('@babel/runtime')
 | |
|     ) {
 | |
|         return 'vendor-3d-maps'; 
 | |
|     }
 | |
|     
 | |
|     if (id.includes('codemirror') || id.includes('react-codemirror2')) {
 | |
|         return 'vendor-codemirror';
 | |
|     }
 | |
| 
 | |
|     if (id.includes('hls.js')) {
 | |
|         return 'vendor-hls';
 | |
|     }
 | |
|     
 | |
|     if (id.includes('pixi.js')) {
 | |
|         return 'vendor-pixijs';
 | |
|     }
 | |
| 
 | |
|     if (id.includes('@mui/material') || id.includes('@mui/icons-material') || id.includes('@mui/x-data-grid')) {
 | |
|         return 'vendor-mui-core';
 | |
|     }
 | |
|     
 | |
|     if (id.includes('/react/') || id.includes('/react-dom/')) {
 | |
|         return 'vendor-react-core';
 | |
|     }
 | |
|     
 | |
|     if (id.includes('react-router') || id.includes('history')) {
 | |
|         return 'vendor-router';
 | |
|     }
 | |
|     
 | |
|     return 'vendor-common-remainder'; 
 | |
|   }
 | |
| 
 | |
|   if (id.includes('src/pages/')) {
 | |
|     const pathParts = id.split('src/pages/');
 | |
|     if (pathParts.length > 1) {
 | |
|         return 'page-' + pathParts[1].split('/')[0].toLowerCase(); 
 | |
|     }
 | |
|   }
 | |
| };
 | |
| 
 | |
| export default defineConfig({
 | |
|   plugins: [
 | |
|     react(), 
 | |
|     tailwindcss(),
 | |
|   ],
 | |
|   resolve: {
 | |
|     alias: {
 | |
|       "@shared": path.resolve(__dirname, "src/shared"),
 | |
|       "@entities": path.resolve(__dirname, "src/entities"),
 | |
|       "@features": path.resolve(__dirname, "src/features"),
 | |
|       "@widgets": path.resolve(__dirname, "src/widgets"),
 | |
|       "@pages": path.resolve(__dirname, "src/pages"),
 | |
|       "@app": path.resolve(__dirname, "src/app"),
 | |
|     },
 | |
|   },
 | |
|   
 | |
|   build: {
 | |
|     chunkSizeWarningLimit: 2000, 
 | |
|     
 | |
|     rollupOptions: {
 | |
|       output: {
 | |
|         manualChunks,
 | |
|         
 | |
|         entryFileNames: `assets/[name]-[hash].js`,
 | |
|         chunkFileNames: `assets/[name]-[hash].js`,
 | |
|         assetFileNames: `assets/[name]-[hash].[ext]`,
 | |
|       }
 | |
|     }
 | |
|   }
 | |
| }) as UserConfigExport; |