- Added DNS prefetch and preconnect links in index.html for improved API loading times. - Implemented lazy loading for tool components to optimize performance and reduce initial load time. - Wrapped tool components in Suspense with a loading fallback to enhance user experience during loading. - Refactored Vite configuration to create manual chunks for better code splitting of React and UI libraries.
38 lines
964 B
TypeScript
38 lines
964 B
TypeScript
import path from "path"
|
|
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import tailwindcss from "@tailwindcss/vite"
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react(), tailwindcss()],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: (id) => {
|
|
// React核心库
|
|
if (id.includes('node_modules/react') ||
|
|
id.includes('node_modules/react-dom') ||
|
|
id.includes('node_modules/react-router-dom')) {
|
|
return 'react-vendor';
|
|
}
|
|
// Radix UI组件
|
|
if (id.includes('node_modules/@radix-ui')) {
|
|
return 'ui-vendor';
|
|
}
|
|
// 图标库
|
|
if (id.includes('node_modules/lucide-react')) {
|
|
return 'icons';
|
|
}
|
|
},
|
|
},
|
|
},
|
|
chunkSizeWarningLimit: 500,
|
|
},
|
|
})
|