From f3b63fdfd97856c4e64be82239c43cd292a35d85 Mon Sep 17 00:00:00 2001 From: fmk1023 Date: Thu, 25 Dec 2025 16:11:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8Esbuild=E5=8E=8B=E7=BC=A9?= =?UTF-8?q?=E3=80=81=E7=A7=BB=E9=99=A4Legacy=E6=8F=92=E4=BB=B6=E3=80=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0optimizeDeps=E3=80=81=E5=8F=96=E6=B6=88chunk?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E8=AE=A1=E7=AE=97=E3=80=81=E6=8F=90=E9=AB=98?= =?UTF-8?q?=E8=B6=85=E5=A4=A7=E9=9D=99=E6=80=81=E8=B5=84=E6=BA=90=E4=B8=B4?= =?UTF-8?q?=E7=95=8C=E5=80=BC=E4=BC=98=E5=8C=96=E6=89=93=E5=8C=85=E9=80=9F?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 152720a..6cc4b4e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,8 +3,8 @@ import { defineConfig, type PluginOption, loadEnv } from 'vite'; import vue from '@vitejs/plugin-vue'; import { visualizer } from "rollup-plugin-visualizer"; import dayjs from "dayjs"; -import basicSSL from '@vitejs/plugin-basic-ssl'; -import legacy from '@vitejs/plugin-legacy' +// import basicSSL from '@vitejs/plugin-basic-ssl'; +// import legacy from '@vitejs/plugin-legacy' const fs = require('node:fs') export default (config: any) => { @@ -20,10 +20,10 @@ export default (config: any) => { } } }), - // 浏览器兼容性 - legacy({ - targets: ['defaults', 'chrome >= 78', 'safari >= 14'], - }), + // // 浏览器兼容性 + // legacy({ + // targets: ['defaults', 'chrome >= 78', 'safari >= 14'], + // }), visualizer({ open: config.mode === 'analysis', }) as PluginOption, @@ -66,16 +66,23 @@ export default (config: any) => { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, - + optimizeDeps: { + include: ['vue', 'dayjs', 'axios'], // 强制预构建常用包 + }, build: { outDir: 'SAP', // 将打包后的文件夹名改为 openRepoPortal // sourcemap: config.mode !== 'production', - minify: 'terser', // 确保使用 terser 进行压缩 - terserOptions: { - compress: { - drop_console: true, // 移除 console.log - }, - }, + // 减少 chunk 大小计算,加快打包速度 + reportCompressedSize: false, + // 提高超大静态资源临界值 + assetsInlineLimit: 4096, + minify: 'esbuild', + // minify: 'terser', // 确保使用 terser 进行压缩 + // terserOptions: { + // compress: { + // drop_console: true, // 移除 console.log + // }, + // }, }, define: {