закрыл задачу 13
This commit is contained in:
		| @@ -1,11 +1,63 @@ | ||||
| import { defineConfig } from "vite"; | ||||
| import { defineConfig, type UserConfigExport } from "vite"; | ||||
| import react from "@vitejs/plugin-react"; | ||||
| import tailwindcss from "@tailwindcss/vite"; | ||||
| import path from "path"; | ||||
|  | ||||
| // https://vite.dev/config/ | ||||
| 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()], | ||||
|   plugins: [ | ||||
|     react(),  | ||||
|     tailwindcss(), | ||||
|   ], | ||||
|   resolve: { | ||||
|     alias: { | ||||
|       "@shared": path.resolve(__dirname, "src/shared"), | ||||
| @@ -16,4 +68,18 @@ export default defineConfig({ | ||||
|       "@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; | ||||
		Reference in New Issue
	
	Block a user