From 6c72344204bdcc1cd263da3feec107848fda5f29 Mon Sep 17 00:00:00 2001 From: sudoooooo Date: Mon, 8 Jul 2024 21:06:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dnginx=E5=90=AF?= =?UTF-8?q?=E5=8A=A8render=E9=A1=B5=E7=A9=BA=E7=99=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/vite.config.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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' + } + } + } + } } })