-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.chunks.ts
More file actions
49 lines (49 loc) · 1.83 KB
/
Copy pathvite.chunks.ts
File metadata and controls
49 lines (49 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* uTools vendor 分包策略。
*
* Vite 8 底层用 rolldown,rollup 的 `output.manualChunks` 会被忽略,
* 必须用 rolldown 原生的 `output.codeSplitting.groups`
* (配 `rolldownOptions.output` 使用;旧名 advancedChunks 已 deprecated)。
*
* 目标:把体积大、更新频率低的第三方库拆成独立 chunk,避免业务代码改动
* 触发整包失效,并让首屏 bundle 更小、缓存命中更稳。
*
* priority 越大越先匹配;命中后该模块从其它组移除。test 用 `[\\/]`
* 兼容 Windows 路径分隔符(rolldown 官方建议)。
*
* 注意:当前业务代码只直接用到 input/tooltip/input-group/dropdown-menu 四个
* ui 组件,recharts / embla / react-day-picker 等仅被未引用的 ui 组件提及,
* 会被 tree-shaking 丢弃;charts 组若无模块命中则不会生成空 chunk。
*/
export const codeSplittingGroups = [
// React 运行时(react / react-dom / scheduler)—— 最稳定,单独长期缓存
{
name: "react-vendor",
test: /[\\/]node_modules[\\/](react|react-dom|scheduler|react-is)[\\/]/,
priority: 50,
},
// @base-ui/react —— 在用组件的底层无障碍原语
{
name: "base-ui",
test: /[\\/]node_modules[\\/]@base-ui[\\/]/,
priority: 40,
},
// 图标库 —— 即便按需引入也常占可观体积,拆出便于观测
{
name: "icons",
test: /[\\/]node_modules[\\/]lucide-react[\\/]/,
priority: 30,
},
// 图表库(recharts 及其 d3-* 依赖);被 tree-shaking 丢弃时此组不生成
{
name: "charts",
test: /[\\/]node_modules[\\/](recharts|d3-[^\\/]+|victory-vendor|internmap)[\\/]/,
priority: 30,
},
// 其余第三方统一归入 vendor(兜底,优先级最低)
{
name: "vendor",
test: /[\\/]node_modules[\\/]/,
priority: 1,
},
];