|
|
@@ -76,6 +76,17 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|
|
target: 'es2020',
|
|
|
cssTarget: 'chrome80',
|
|
|
outDir: OUTPUT_DIR,
|
|
|
+ // [perf-base-v1] 卡3: modulePreload 收敛——html 入口不再预加载 office-preview/markdown-vendor/
|
|
|
+ // tinymce/html2canvas/codemirror/cron-parser 等重包(已改异步按需加载),保留 echarts-vendor 等首屏真实依赖。
|
|
|
+ // context 参数用宽类型注解以兼容 Vite4(hostType:'html'|'js'|'css'|'asset') 与 Vite5 类型差异。
|
|
|
+ modulePreload: {
|
|
|
+ polyfill: true,
|
|
|
+ resolveDependencies: (url: string, deps: string[], context: { hostType: string }) => {
|
|
|
+ const heavy = /office-preview|markdown-vendor|tinymce-vendor|html2canvas|codemirror|cron-parser/;
|
|
|
+ if (context.hostType === 'html') return deps.filter((d) => !heavy.test(d));
|
|
|
+ return deps.filter((d) => !/office-preview|markdown-vendor/.test(d));
|
|
|
+ },
|
|
|
+ },
|
|
|
rollupOptions: {
|
|
|
output: {
|
|
|
chunkFileNames: 'js/[name]-[hash].js', // 引入文件名的名称
|