diff --git a/web/vite.config.ts b/web/vite.config.ts index 1d36bdcf..f8527f21 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -2,7 +2,9 @@ import { fileURLToPath, URL } from 'node:url' import { defineConfig, normalizePath } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' + import { createMpaPlugin, createPages } from 'vite-plugin-virtual-mpa' + import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import Icons from 'unplugin-icons/vite' @@ -116,6 +118,31 @@ export default defineConfig({ } }, build: { - rollupOptions: {} + rollupOptions: { + output: { + assetFileNames: '[ext]/[name]-[hash].[ext]', + chunkFileNames: 'js/[name]-[hash].js', + entryFileNames: 'js/[name]-[hash].js', + manualChunks(id) { + // 建议根据项目生产实际情况进行优化,部分可走cdn或进行小资源包合并 + if (id.includes('element-plus')) { + return 'element-plus' + } + if (id.includes('wangeditor')) { + return 'wangeditor' + } + if (id.includes('node-forg')) { + return 'node-forg' + } + if (id.includes('echarts')) { + return 'echarts' + } + + if (id.includes('node_modules')) { + return 'packages' + } + } + } + } } })