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: {