[{"data":1,"prerenderedAt":760},["ShallowReactive",2],{"post-\u002Fblog\u002F2026-08-24-genesis-vite-preload-first-screen":3,"surround-\u002Fblog\u002F2026-08-24-genesis-vite-preload-first-screen":753},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":11,"body":15,"_type":747,"_id":748,"_source":749,"_file":750,"_stem":751,"_extension":752},"\u002Fblog\u002F2026-08-24-genesis-vite-preload-first-screen","blog",false,"","首屏 JS 从 1462KB 降到 523KB：毛病出在一个 200 字节的预加载函数上","Vite 的预加载助手被分进了 monaco chunk，连登录页都得先下载整个 Monaco 编辑器。把它单独分一组，首屏 gzip 降到 523KB。","2026-08-24",[12,13,14],"Genesis","前端性能","Vite",{"type":16,"children":17,"toc":739},"root",[18,32,37,44,49,87,124,145,150,156,161,284,297,302,311,316,321,326,496,501,604,609,617,622,635,640,645,692,697,703,716,728,733],{"type":19,"tag":20,"props":21,"children":22},"element","p",{},[23,30],{"type":19,"tag":24,"props":25,"children":27},"a",{"href":26},"\u002Fprojects\u002Fgenesis\u002F",[28],{"type":29,"value":12},"text",{"type":29,"value":31}," 的前端是 Vue 3 + Vite，路由全是懒加载，照理说打开登录页只该下载登录页自己的代码。8 月 21 号我按 index.html 里 modulepreload 实际列出的文件量了一下（modulepreload 是浏览器一打开页面就会提前下载的 JS 清单），首屏 JS 在 gzip 之后是 1462KB，登录页也一样。原来文档里写的是「首屏 gz ~1.3MB」，那是拿 chunk 体积估出来的，真量出来还要更大。",{"type":19,"tag":20,"props":33,"children":34},{},[35],{"type":29,"value":36},"下面的过程是根据当时的提交说明和 Phase 1 优化文档整理的。",{"type":19,"tag":38,"props":39,"children":41},"h2",{"id":40},"先做的两项首屏一点没少",[42],{"type":29,"value":43},"先做的两项，首屏一点没少",{"type":19,"tag":20,"props":45,"children":46},{},[47],{"type":29,"value":48},"Phase 1 给前端定的目标是首屏 JS gzip 后小于 300KB。一开始的思路很直接：IDE 那几个大组件和 Monaco 编辑器（就是 VS Code 用的那个网页代码编辑器）最重，把它们拆出去就行。这两项是派给 AI 编程会话做的，当天先后做完。",{"type":19,"tag":20,"props":50,"children":51},{},[52,54,61,63,69,71,77,79,85],{"type":29,"value":53},"第一项是把 IDE 组件改成异步加载。计划里是把 IdeLayout 静态导入的 8 个组件逐个改成异步，实际只动了下面一层：EditorPane 里静态导入的 6 个编辑器，加上 BottomPanel 里的 ProblemsPanel，一共 7 个改成 ",{"type":19,"tag":55,"props":56,"children":58},"code",{"className":57},[],[59],{"type":29,"value":60},"defineAsyncComponent",{"type":29,"value":62},"，也就是用到时才去下载这个组件。这 7 个才是真正重的：DataTransferEditor 一个文件就有 5154 行，WorkflowCanvas 静态拖着 756KB 的 @antv\u002Fx6，4 个编辑器各自拖着 Monaco。没包 ",{"type":19,"tag":55,"props":64,"children":66},{"className":65},[],[67],{"type":29,"value":68},"\u003CSuspense>",{"type":29,"value":70},"，用 ",{"type":19,"tag":55,"props":72,"children":74},{"className":73},[],[75],{"type":29,"value":76},"loadingComponent",{"type":29,"value":78}," 加 200ms 的 ",{"type":19,"tag":55,"props":80,"children":82},{"className":81},[],[83],{"type":29,"value":84},"delay",{"type":29,"value":86}," 做占位。改完以后 IdeLayout 这个 chunk 从 815KB 降到 689KB（gzip），少了 126KB。",{"type":19,"tag":20,"props":88,"children":89},{},[90,92,98,100,106,108,114,116,122],{"type":29,"value":91},"第二项是裁剪 Monaco，这一项原来的判断也错了一半。计划里以为是 vite-plugin-monaco-editor 的 ",{"type":19,"tag":55,"props":93,"children":95},{"className":94},[],[96],{"type":29,"value":97},"languageWorkers",{"type":29,"value":99}," 配错了，一查，这个配置从第一个提交起就是 ",{"type":19,"tag":55,"props":101,"children":103},{"className":102},[],[104],{"type":29,"value":105},"['editorWorkerService']",{"type":29,"value":107},"，一直是对的。那几个语言 worker 是 monaco-editor 自己的 workerManager.js 里写了 ",{"type":19,"tag":55,"props":109,"children":111},{"className":110},[],[112],{"type":29,"value":113},"new Worker(new URL(...))",{"type":29,"value":115},"，Vite 认得这种写法，自动拆成了 chunk，跟插件配置没关系。真正把它们拉进来的是代码里的 ",{"type":19,"tag":55,"props":117,"children":119},{"className":118},[],[120],{"type":29,"value":121},"import * as monaco from 'monaco-editor'",{"type":29,"value":123},"，它会引入整个 editor.main，里面带着 4 个语言服务和 87 种语法高亮。",{"type":19,"tag":20,"props":125,"children":126},{},[127,129,135,137,143],{"type":29,"value":128},"改法是只组合编辑器内核，再加上实际用到的 sql、python、shell 三种语法。改成深路径导入时还踩了个坑：monaco-editor 的 package.json 里，exports 写的是 ",{"type":19,"tag":55,"props":130,"children":132},{"className":131},[],[133],{"type":29,"value":134},"\".\u002F*\": \".\u002F*\"",{"type":29,"value":136},"，不带扩展名的子路径会被原样映射成一个不存在的文件。Vite 运行时会自动补扩展名，所以构建完全没感觉；TypeScript 在 exports 映射下却不补，类型检查报 TS2307（找不到模块）。所以深路径必须写全 ",{"type":19,"tag":55,"props":138,"children":140},{"className":139},[],[141],{"type":29,"value":142},".js",{"type":29,"value":144},"。改完以后产物总量从 20.51M 降到 11.30M，ts、css、html、json 四个 worker 一共 8.71MB 都没了。",{"type":19,"tag":20,"props":146,"children":147},{},[148],{"type":29,"value":149},"两份结果单看都不错，可首屏还是 1462KB。原因说穿了很简单：IdeLayout 是路由级 chunk，那几个 worker 本来也是用到才加载，它们都不在首屏要下载的那一批里。东西确实变小了，可变小的部分本来就不在首屏。",{"type":19,"tag":38,"props":151,"children":153},{"id":152},"入口-chunk-里的一行-import",[154],{"type":29,"value":155},"入口 chunk 里的一行 import",{"type":19,"tag":20,"props":157,"children":158},{},[159],{"type":29,"value":160},"IdeLayout 拆完以后，我再按 index.html 的口径量了一次，首屏从 1462K 变成 1463K，一点没少。重量既然不在路由 chunk 里，就只能去看入口 chunk 到底静态 import 了什么。翻开构建产物，入口里有这么两行：",{"type":19,"tag":162,"props":163,"children":167},"pre",{"className":164,"code":165,"language":166,"meta":7,"style":7},"language-js shiki shiki-themes github-light github-dark","import{_ as R}from\".\u002Fmonaco-*.js\"\ncomponent: () => R(() => import(\".\u002FLoginView-*.js\"), __vite__mapDeps([...]))\n","js",[168],{"type":19,"tag":55,"props":169,"children":170},{"__ignoreMap":7},[171,210],{"type":19,"tag":172,"props":173,"children":176},"span",{"class":174,"line":175},"line",1,[177,183,189,194,199,204],{"type":19,"tag":172,"props":178,"children":180},{"style":179},"--shiki-default:#D73A49;--shiki-dark:#F97583",[181],{"type":29,"value":182},"import",{"type":19,"tag":172,"props":184,"children":186},{"style":185},"--shiki-default:#24292E;--shiki-dark:#E1E4E8",[187],{"type":29,"value":188},"{_ ",{"type":19,"tag":172,"props":190,"children":191},{"style":179},[192],{"type":29,"value":193},"as",{"type":19,"tag":172,"props":195,"children":196},{"style":185},[197],{"type":29,"value":198}," R}",{"type":19,"tag":172,"props":200,"children":201},{"style":179},[202],{"type":29,"value":203},"from",{"type":19,"tag":172,"props":205,"children":207},{"style":206},"--shiki-default:#032F62;--shiki-dark:#9ECBFF",[208],{"type":29,"value":209},"\".\u002Fmonaco-*.js\"\n",{"type":19,"tag":172,"props":211,"children":213},{"class":174,"line":212},2,[214,220,225,230,235,240,244,249,254,259,264,269,274,279],{"type":19,"tag":172,"props":215,"children":217},{"style":216},"--shiki-default:#6F42C1;--shiki-dark:#B392F0",[218],{"type":29,"value":219},"component",{"type":19,"tag":172,"props":221,"children":222},{"style":185},[223],{"type":29,"value":224},": () ",{"type":19,"tag":172,"props":226,"children":227},{"style":179},[228],{"type":29,"value":229},"=>",{"type":19,"tag":172,"props":231,"children":232},{"style":216},[233],{"type":29,"value":234}," R",{"type":19,"tag":172,"props":236,"children":237},{"style":185},[238],{"type":29,"value":239},"(() ",{"type":19,"tag":172,"props":241,"children":242},{"style":179},[243],{"type":29,"value":229},{"type":19,"tag":172,"props":245,"children":246},{"style":179},[247],{"type":29,"value":248}," import",{"type":19,"tag":172,"props":250,"children":251},{"style":185},[252],{"type":29,"value":253},"(",{"type":19,"tag":172,"props":255,"children":256},{"style":206},[257],{"type":29,"value":258},"\".\u002FLoginView-*.js\"",{"type":19,"tag":172,"props":260,"children":261},{"style":185},[262],{"type":29,"value":263},"), ",{"type":19,"tag":172,"props":265,"children":266},{"style":216},[267],{"type":29,"value":268},"__vite__mapDeps",{"type":19,"tag":172,"props":270,"children":271},{"style":185},[272],{"type":29,"value":273},"([",{"type":19,"tag":172,"props":275,"children":276},{"style":179},[277],{"type":29,"value":278},"...",{"type":19,"tag":172,"props":280,"children":281},{"style":185},[282],{"type":29,"value":283},"]))\n",{"type":19,"tag":20,"props":285,"children":286},{},[287,289,295],{"type":29,"value":288},"这个 R 是 Vite 的动态导入预加载助手 ",{"type":19,"tag":55,"props":290,"children":292},{"className":291},[],[293],{"type":29,"value":294},"__vitePreload",{"type":29,"value":296},"。懒加载一个页面时，Vite 会用它包一层，顺手把这个页面依赖的其他文件也提前下载。路由里每个懒加载组件外面都包了它，一共 87 个路由在调。",{"type":19,"tag":20,"props":298,"children":299},{},[300],{"type":29,"value":301},"函数本身大概 200 字节，却被打进了 monaco 那个 chunk。入口要用它，就只能静态 import 整个 monaco chunk：3.55MB，gzip 后 941KB。ES 模块的静态 import 要等依赖下载、执行完，入口代码才会开始跑，所以入口哪怕只用了这个 chunk 里的一个函数，整块也得先到位，路由才能工作。index.html 的 modulepreload 里于是就是 antd 和 monaco 两大块，用户哪怕只是打开登录页，也得先把整个 Monaco 下完。",{"type":19,"tag":20,"props":303,"children":304},{},[305],{"type":19,"tag":306,"props":307,"children":310},"img",{"alt":308,"src":309},"改前改后对比：改前，入口 chunk 静态引入 monaco chunk（3.55MB，gzip 941KB，里面混着 __vitePreload），首屏 JS raw 5.23M、gzip 1462K；改后，入口只静态引入 antd 和 gzip 后 1K 的 vite-runtime，monaco 在打开 SQL 编辑页时才加载，首屏 JS raw 1.68M、gzip 523K","\u002Fimages\u002Fblog\u002Fgenesis-vite-preload\u002Fpreload-chain.svg",[],{"type":19,"tag":20,"props":312,"children":313},{},[314],{"type":29,"value":315},"为什么会落在 monaco 里：vite.config.ts 用 manualChunks 按模块 id 手动分了几组，monaco、antv-x6、echarts、antd 各一组。这个助手自己没被分进任何一组，结果被一个大 vendor 组收了进去，实测落进的是 monaco。这个问题从项目第一个提交起就在，之前没有任何文档提到过。",{"type":19,"tag":38,"props":317,"children":319},{"id":318},"改法只有一行",[320],{"type":29,"value":318},{"type":19,"tag":20,"props":322,"children":323},{},[324],{"type":29,"value":325},"这个发现本来不在计划里。当晚我先在主线 UX 的设计文档里把它记成计划外发现，打算以后作为分包专项单独做；结果没等专项，从记下来到提交修复不到半小时，事后在 Phase 1 的任务表里补记成 P1-F03b。改动就是在 manualChunks 里给这个助手单独一个组：",{"type":19,"tag":162,"props":327,"children":331},{"className":328,"code":329,"language":330,"meta":7,"style":7},"language-ts shiki shiki-themes github-light github-dark","manualChunks: (id: string) => {\n  \u002F\u002F Vite 的动态导入预加载助手（__vitePreload）必须独立成 chunk\n  if (id.includes('vite\u002Fpreload-helper')) return 'vite-runtime'\n  \u002F\u002F Monaco Editor ~3.7MB → separate chunk\n  if (id.includes('monaco-editor')) return 'monaco'\n  \u002F\u002F antv-x6、echarts、antd 的分组不变\n},\n","ts",[332],{"type":19,"tag":55,"props":333,"children":334},{"__ignoreMap":7},[335,379,388,431,440,478,487],{"type":19,"tag":172,"props":336,"children":337},{"class":174,"line":175},[338,343,348,354,359,365,370,374],{"type":19,"tag":172,"props":339,"children":340},{"style":216},[341],{"type":29,"value":342},"manualChunks",{"type":19,"tag":172,"props":344,"children":345},{"style":185},[346],{"type":29,"value":347},": (",{"type":19,"tag":172,"props":349,"children":351},{"style":350},"--shiki-default:#E36209;--shiki-dark:#FFAB70",[352],{"type":29,"value":353},"id",{"type":19,"tag":172,"props":355,"children":356},{"style":179},[357],{"type":29,"value":358},":",{"type":19,"tag":172,"props":360,"children":362},{"style":361},"--shiki-default:#005CC5;--shiki-dark:#79B8FF",[363],{"type":29,"value":364}," string",{"type":19,"tag":172,"props":366,"children":367},{"style":185},[368],{"type":29,"value":369},") ",{"type":19,"tag":172,"props":371,"children":372},{"style":179},[373],{"type":29,"value":229},{"type":19,"tag":172,"props":375,"children":376},{"style":185},[377],{"type":29,"value":378}," {\n",{"type":19,"tag":172,"props":380,"children":381},{"class":174,"line":212},[382],{"type":19,"tag":172,"props":383,"children":385},{"style":384},"--shiki-default:#6A737D;--shiki-dark:#6A737D",[386],{"type":29,"value":387},"  \u002F\u002F Vite 的动态导入预加载助手（__vitePreload）必须独立成 chunk\n",{"type":19,"tag":172,"props":389,"children":391},{"class":174,"line":390},3,[392,397,402,407,411,416,421,426],{"type":19,"tag":172,"props":393,"children":394},{"style":179},[395],{"type":29,"value":396},"  if",{"type":19,"tag":172,"props":398,"children":399},{"style":185},[400],{"type":29,"value":401}," (id.",{"type":19,"tag":172,"props":403,"children":404},{"style":216},[405],{"type":29,"value":406},"includes",{"type":19,"tag":172,"props":408,"children":409},{"style":185},[410],{"type":29,"value":253},{"type":19,"tag":172,"props":412,"children":413},{"style":206},[414],{"type":29,"value":415},"'vite\u002Fpreload-helper'",{"type":19,"tag":172,"props":417,"children":418},{"style":185},[419],{"type":29,"value":420},")) ",{"type":19,"tag":172,"props":422,"children":423},{"style":179},[424],{"type":29,"value":425},"return",{"type":19,"tag":172,"props":427,"children":428},{"style":206},[429],{"type":29,"value":430}," 'vite-runtime'\n",{"type":19,"tag":172,"props":432,"children":434},{"class":174,"line":433},4,[435],{"type":19,"tag":172,"props":436,"children":437},{"style":384},[438],{"type":29,"value":439},"  \u002F\u002F Monaco Editor ~3.7MB → separate chunk\n",{"type":19,"tag":172,"props":441,"children":443},{"class":174,"line":442},5,[444,448,452,456,460,465,469,473],{"type":19,"tag":172,"props":445,"children":446},{"style":179},[447],{"type":29,"value":396},{"type":19,"tag":172,"props":449,"children":450},{"style":185},[451],{"type":29,"value":401},{"type":19,"tag":172,"props":453,"children":454},{"style":216},[455],{"type":29,"value":406},{"type":19,"tag":172,"props":457,"children":458},{"style":185},[459],{"type":29,"value":253},{"type":19,"tag":172,"props":461,"children":462},{"style":206},[463],{"type":29,"value":464},"'monaco-editor'",{"type":19,"tag":172,"props":466,"children":467},{"style":185},[468],{"type":29,"value":420},{"type":19,"tag":172,"props":470,"children":471},{"style":179},[472],{"type":29,"value":425},{"type":19,"tag":172,"props":474,"children":475},{"style":206},[476],{"type":29,"value":477}," 'monaco'\n",{"type":19,"tag":172,"props":479,"children":481},{"class":174,"line":480},6,[482],{"type":19,"tag":172,"props":483,"children":484},{"style":384},[485],{"type":29,"value":486},"  \u002F\u002F antv-x6、echarts、antd 的分组不变\n",{"type":19,"tag":172,"props":488,"children":490},{"class":174,"line":489},7,[491],{"type":19,"tag":172,"props":492,"children":493},{"style":185},[494],{"type":29,"value":495},"},\n",{"type":19,"tag":20,"props":497,"children":498},{},[499],{"type":29,"value":500},"改完再量：",{"type":19,"tag":502,"props":503,"children":504},"table",{},[505,527],{"type":19,"tag":506,"props":507,"children":508},"thead",{},[509],{"type":19,"tag":510,"props":511,"children":512},"tr",{},[513,517,522],{"type":19,"tag":514,"props":515,"children":516},"th",{},[],{"type":19,"tag":514,"props":518,"children":519},{},[520],{"type":29,"value":521},"改前",{"type":19,"tag":514,"props":523,"children":524},{},[525],{"type":29,"value":526},"改后",{"type":19,"tag":528,"props":529,"children":530},"tbody",{},[531,550,568,586],{"type":19,"tag":510,"props":532,"children":533},{},[534,540,545],{"type":19,"tag":535,"props":536,"children":537},"td",{},[538],{"type":29,"value":539},"首屏 JS（raw）",{"type":19,"tag":535,"props":541,"children":542},{},[543],{"type":29,"value":544},"5.23M",{"type":19,"tag":535,"props":546,"children":547},{},[548],{"type":29,"value":549},"1.68M",{"type":19,"tag":510,"props":551,"children":552},{},[553,558,563],{"type":19,"tag":535,"props":554,"children":555},{},[556],{"type":29,"value":557},"首屏 JS（gzip）",{"type":19,"tag":535,"props":559,"children":560},{},[561],{"type":29,"value":562},"1462K",{"type":19,"tag":535,"props":564,"children":565},{},[566],{"type":29,"value":567},"523K",{"type":19,"tag":510,"props":569,"children":570},{},[571,576,581],{"type":19,"tag":535,"props":572,"children":573},{},[574],{"type":29,"value":575},"modulepreload",{"type":19,"tag":535,"props":577,"children":578},{},[579],{"type":29,"value":580},"antd + monaco",{"type":19,"tag":535,"props":582,"children":583},{},[584],{"type":29,"value":585},"antd + vite-runtime（gzip 后 1K）",{"type":19,"tag":510,"props":587,"children":588},{},[589,594,599],{"type":19,"tag":535,"props":590,"children":591},{},[592],{"type":29,"value":593},"monaco chunk",{"type":19,"tag":535,"props":595,"children":596},{},[597],{"type":29,"value":598},"首屏必下",{"type":19,"tag":535,"props":600,"children":601},{},[602],{"type":29,"value":603},"打开编辑器时才拉",{"type":19,"tag":20,"props":605,"children":606},{},[607],{"type":29,"value":608},"gzip 后少了 939K，降了 64%。",{"type":19,"tag":20,"props":610,"children":611},{},[612],{"type":19,"tag":306,"props":613,"children":616},{"alt":614,"src":615},"首屏 JS gzip 体积变化：最初实测 1462K；IDE 组件异步化之后 1463K，其间 IdeLayout chunk 从 815K 降到 689K；预加载助手单独分组之后 523K，少了 64%；再把图标单独拆一个 chunk 后 516K；Phase 1 目标 300KB 用红色虚线标出","\u002Fimages\u002Fblog\u002Fgenesis-vite-preload\u002Ffirst-screen-numbers.svg",[],{"type":19,"tag":38,"props":618,"children":620},{"id":619},"必须在浏览器里验",[621],{"type":29,"value":619},{"type":19,"tag":20,"props":623,"children":624},{},[625,627,633],{"type":29,"value":626},"这一行改动的风险其实不小。助手换了 chunk，要是哪里没接上，87 个懒加载路由会一起挂，而光看构建产物是看不出来的。所以这次验收要求必须做运行时验证：把生产构建产物放到静态服务器上，用无头浏览器去跑。登录页确认没有拉 monaco，LoginView 的懒加载 chunk 正常加载；切到 \u002Fdemo\u002Fsql-workspace，monaco 按需拉下来，",{"type":19,"tag":55,"props":628,"children":630},{"className":629},[],[631],{"type":29,"value":632},".monaco-editor",{"type":29,"value":634}," 挂载成功；全程没有失败请求，也没有页面报错。",{"type":19,"tag":38,"props":636,"children":638},{"id":637},"以后首屏只认两样东西",[639],{"type":29,"value":637},{"type":19,"tag":20,"props":641,"children":642},{},[643],{"type":29,"value":644},"这件事之后，我把首屏的验收口径改了。前两项优化的报告里写的是 chunk 体积、产物总量、worker 数量，这些都只是间接指标，跟首屏可能毫无关系。现在 Phase 1 文档最上面写着：首屏 JS 只看 index.html 里 modulepreload 和 script src 的集合，再加上入口 chunk 的静态 import。后者一行命令就能列出来：",{"type":19,"tag":162,"props":646,"children":650},{"className":647,"code":648,"language":649,"meta":7,"style":7},"language-bash shiki shiki-themes github-light github-dark","grep -oE 'from\"\\.\u002F[^\"]+\\.js\"' \u003C入口chunk>\n","bash",[651],{"type":19,"tag":55,"props":652,"children":653},{"__ignoreMap":7},[654],{"type":19,"tag":172,"props":655,"children":656},{"class":174,"line":175},[657,662,667,672,677,682,687],{"type":19,"tag":172,"props":658,"children":659},{"style":216},[660],{"type":29,"value":661},"grep",{"type":19,"tag":172,"props":663,"children":664},{"style":361},[665],{"type":29,"value":666}," -oE",{"type":19,"tag":172,"props":668,"children":669},{"style":206},[670],{"type":29,"value":671}," 'from\"\\.\u002F[^\"]+\\.js\"'",{"type":19,"tag":172,"props":673,"children":674},{"style":179},[675],{"type":29,"value":676}," \u003C",{"type":19,"tag":172,"props":678,"children":679},{"style":206},[680],{"type":29,"value":681},"入口chun",{"type":19,"tag":172,"props":683,"children":684},{"style":185},[685],{"type":29,"value":686},"k",{"type":19,"tag":172,"props":688,"children":689},{"style":179},[690],{"type":29,"value":691},">\n",{"type":19,"tag":20,"props":693,"children":694},{},[695],{"type":29,"value":696},"谁再说做了首屏优化，就得拿出改前改后的 modulepreload 集合对比。",{"type":19,"tag":38,"props":698,"children":700},{"id":699},"还剩-antd",[701],{"type":29,"value":702},"还剩 antd",{"type":19,"tag":20,"props":704,"children":705},{},[706,708,714],{"type":29,"value":707},"523KB 离 300KB 还差一截，剩下的基本都是 antd（Ant Design Vue 组件库）。main.ts 里是 ",{"type":19,"tag":55,"props":709,"children":711},{"className":710},[],[712],{"type":29,"value":713},"app.use(Antd)",{"type":29,"value":715}," 全量注册，文档里记的是 antd 占 438KB，是首屏 523KB 的 84%。",{"type":19,"tag":20,"props":717,"children":718},{},[719,721,726],{"type":29,"value":720},"我试过一个省事的办法：把 @ant-design\u002Ficons-vue 单独拆成一个 chunk，首屏从 523KB 到 516KB，只少了 7KB。图标是 antd 组件内部引用的，只要 ",{"type":19,"tag":55,"props":722,"children":724},{"className":723},[],[725],{"type":29,"value":713},{"type":29,"value":727}," 还在，整个 antd 就在入口的静态依赖里，怎么拆 chunk 都改变不了这层引用关系。得从 main.ts 的注册方式下手，换成 unplugin-vue-components 加 AntDesignVueResolver 按需引入，也就是模板里用到哪个组件，构建时才引入哪个。",{"type":19,"tag":20,"props":729,"children":730},{},[731],{"type":29,"value":732},"这一刀也没想象中那么好砍。模板里实际用到了 69 种 antd 组件、155 种图标，真没用上的组件不多，能省下来的主要靠把各个路由专用的组件推迟到路由 chunk 里。项目里目前还没装 unplugin-vue-components，这一项排在 Phase 1 的 P1-F04，还没开始。",{"type":19,"tag":734,"props":735,"children":736},"style",{},[737],{"type":29,"value":738},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":7,"searchDepth":390,"depth":390,"links":740},[741,742,743,744,745,746],{"id":40,"depth":212,"text":43},{"id":152,"depth":212,"text":155},{"id":318,"depth":212,"text":318},{"id":619,"depth":212,"text":619},{"id":637,"depth":212,"text":637},{"id":699,"depth":212,"text":702},"markdown","content:blog:2026-08-24-genesis-vite-preload-first-screen.md","content","blog\u002F2026-08-24-genesis-vite-preload-first-screen.md","blog\u002F2026-08-24-genesis-vite-preload-first-screen","md",[754,757],{"_path":755,"title":756},"\u002Fblog\u002F2026-08-30-local-ai-cluster-architecture","家里两台 DGX Spark：推理集群现在怎么搭的，之前换过几轮",{"_path":758,"title":759},"\u002Fblog\u002F2026-08-22-genesis-onedata-standards","数仓命名靠词根管：Genesis 的数据标准和 OneData 建模是怎么设计的",1796523532783]