Skip to content

refactor(nav): migrate tabler icons from CDN webfont to @tabler/icons-vue SVG - #26

Merged
joke-lx merged 1 commit into
mainfrom
refactor/nav-icons-svg
Aug 19, 2026
Merged

refactor(nav): migrate tabler icons from CDN webfont to @tabler/icons-vue SVG#26
joke-lx merged 1 commit into
mainfrom
refactor/nav-icons-svg

Conversation

@joke-lx

@joke-lx joke-lx commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

改动概要

把两个导航组件 (bottom-nav-capsule-v3 / mobile-nav-v5) 从运行时 CDN webfont 切到 npm @tabler/icons-vue SVG 组件,彻底脱离 jsdelivr 外部依赖。

Why

原方案在组件 scoped CSS 里写 @import url('https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3/dist/tabler-icons.min.css'),作为运行时跨域请求拉取。该方式有两类问题:

  1. 可达性:jsdelivr 在代理环境下偶尔不可达 → icon 字符回退为方框
  2. 重量:@tabler/icons-webfont@^3 包把所有 ~5000 个 icon 字符 + woff2/woff/ttf 全塞进单一字体,且生产 dependencies 包含 svgtofont 等构建工具链,lockfile 净增 ~141 个传递包

What

  • 新增依赖: @tabler/icons-vue@^3.46.0 (净 +13/-141 包)
  • icon 渲染: <i class="ti ti-X"><component :is="tab.icon"> + Tab.icon: Component 类型化引用 (IconLayoutList/IconSteeringWheel/IconPackage / IconHome/IconSearch/IconBell/IconHeart/IconUser)
  • 样式调整: SVG 取代 <i>,font-sizewidth/height,line-height: 1 删除,color 保留 (SVG stroke="currentColor" 继承)
  • 删除 scoped CSS 里的 @import url(...) CDN 引用
  • 测试 fixture 更新: apps/showcase/__tests__/scoped-id.test.ts 两个 SFC 的 prod scopedId 从 703dbc6e/63f19fc5 改到 03e87072/9cb8b630 (LF 归一哈希)

Net effect

改前 改后
vc-bottom-nav-capsule-v3-*.css 201,722 B 1,088 B (-99.5%)
dist/assets/tabler-icons-*.woff2 etc. ~4.2MB 字体 0 (无字体请求)
lockfile 传递依赖 +250 包(webfont 工具链) +13 包

Verification

  • pnpm --filter @style-library/showcase build 干净
  • pnpm exec vitest run 439/439 通过
  • pnpm lint 干净
  • ✅ 运行时 scopedId (03e87072 / 9cb8b630) CSS 与 JS 字节级对齐
  • ✅ 0 个 jsdelivr / tabler 字体字符串留在 dist

…-vue SVG

bottom-nav-capsule-v3 and mobile-nav-v5 used to load the tabler-icons webfont
via a runtime CDN `@import url(...)` inside scoped CSS. This was reachable-but-
fragile: blocked when jsdelivr was unreachable behind a proxy, added a render-
blocking cross-origin font request, and required ShadowRoot style adoption to
inherit a font CSS chain.

Switch both components to `@tabler/icons-vue@^3.46.0` SVG components
(IconLayoutList / IconSteeringWheel / IconPackage for v3; IconHome / IconSearch
/ IconBell / IconHeart / IconUser for v5), rendered via `<component :is="tab.icon">`.
SVG strokes use `currentColor` so existing CSS `color` rules keep working;
`font-size` replaced with `width`/`height`; `line-height: 1` dropped.

Net effect:
- zero external CDN requests at runtime
- zero font bytes in dist/assets/
- vc-bottom-nav-capsule-v3-*.css shrinks 201722 B → 1088 B (-99.5%)
- lockfile +13/-141 (webfont build-toolchain removed)

Verification: pnpm --filter @style-library/showcase build clean, 439/439 vitest,
lint clean, scoped-id fixtures updated (LF-normalized values 03e87072 / 9cb8b630).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joke-lx
joke-lx merged commit f54534d into main Aug 19, 2026
3 checks passed
@joke-lx
joke-lx deleted the refactor/nav-icons-svg branch August 19, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant