Skip to content

Commit db0c912

Browse files
frankslinsudoghut
authored andcommitted
fix(font): 從 Vite 中移除 Noto Sans TC 字型;改由 Google Fonts 加載
移除 @fontsource/noto-sans-tc 依賴,以及 app.js / Inertia app.tsx 中的 300、400、700 weight CSS import。這批字型原本由 Vite 打包成大量 hashed woff/woff2,導致每次 release 都產生新的字型檔名稱與 manifest 資產列表。 此舉並非移除 CJK webfont:主站與 Inertia 模板仍透過 Google Fonts 載入 Noto Sans TC,CSS 字體棧也保留 Source Sans Pro + Noto Sans TC。CBDB API 頁面同樣保留 Google Fonts 的 Noto Sans TC 載入。 頁面不會因為移除 @fontsource 而無法載入:Noto Sans TC 仍由 Google Fonts 提供;若外部字型未載入,瀏覽器仍會回退到系統 sans 字型。npm run build 已確認通過,Vite 產物中不再出現 noto-sans-tc-* hashed 字型資產。 此改動會大幅減少編譯產物體積,並減少訪問 CBDB 站的網路帶寬。
1 parent c0712b3 commit db0c912

9 files changed

Lines changed: 9 additions & 27 deletions

File tree

package-lock.json

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"vue": "^3.0.0"
2929
},
3030
"dependencies": {
31-
"@fontsource/noto-sans-tc": "^5.2.9",
3231
"@inertiajs/react": "^2.3.18",
3332
"@radix-ui/react-dialog": "^1.1.17",
3433
"@radix-ui/react-label": "^2.1.10",

public/cbdbapi/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<!-- Bootstrap CSS -->
1010
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
1111
<!-- Google Fonts -->
12-
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&display=swap" rel="stylesheet">
12+
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&display=fallback" rel="stylesheet">
1313

1414
<style>
1515
* {

resources/css/inertia.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
--radius-md: var(--radius);
231231
--radius-lg: calc(var(--radius) + 2px);
232232

233-
/* 字體:沿用主站 Source Sans Pro / Noto Sans TC(見近期 commit) */
233+
/* 字體:Source Sans Pro / Noto Sans TC 由模板走 Google Fonts 載入,不進 Vite bundle。 */
234234
--font-sans: 'Source Sans Pro', 'Noto Sans TC', -apple-system, BlinkMacSystemFont,
235235
'Segoe UI', Roboto, sans-serif;
236236

resources/js/app.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
// Import AdminLTE v3 CSS from NPM
99
import 'admin-lte/dist/css/adminlte.min.css';
1010

11-
// Self-hosted Noto Sans TC (weights matching Source Sans Pro) — no Google CDN dependency
12-
import '@fontsource/noto-sans-tc/300.css';
13-
import '@fontsource/noto-sans-tc/400.css';
14-
import '@fontsource/noto-sans-tc/700.css';
15-
1611
// Import jQuery and expose globally before any plugins run
1712
import $ from './jquery-global';
1813

resources/js/inertia/app.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ import { createInertiaApp } from '@inertiajs/react';
22
import { createRoot } from 'react-dom/client';
33
// Tailwind v4 + 設計 token(僅此 inertia bundle 載入,不影響 Blade/AdminLTE)
44
import '../../css/inertia.css';
5-
// 字體與主站對齊:Noto Sans TC 自托管(@fontsource,與 app.js 一致),修正 zh-TW 偏細;
6-
// Source Sans Pro 由 inertia.blade.php 的 Google Font link 載入(與 dashboard-v3 同法)。
7-
// 先前 /app 只在 inertia.css 宣告字體名卻未載入字體,導致中文掉回系統 CJK(偏細)。
8-
import '@fontsource/noto-sans-tc/300.css';
9-
import '@fontsource/noto-sans-tc/400.css';
10-
import '@fontsource/noto-sans-tc/700.css';
5+
// Source Sans Pro / Noto Sans TC 由 inertia.blade.php 的 Google Fonts link 載入(與 dashboard-v3 同法);
6+
// 不再由 @fontsource 進入 Vite bundle,避免每次 build 產生大量 hashed Noto webfont。
117
import { installNumberInputWheelGuard } from '../utils/disableNumberInputWheel';
128

139
installNumberInputWheelGuard();

resources/views/cbdbapi/person.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<!-- Bootstrap CSS -->
1010
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
1111
<!-- Google Fonts -->
12-
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&display=swap" rel="stylesheet">
12+
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&display=fallback" rel="stylesheet">
1313

1414
<style>
1515
* {

resources/views/inertia.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<meta name="csrf-token" content="{{ csrf_token() }}">
7-
{{-- Google Font: Source Sans Pro(與主站 dashboard-v3 對齊;Noto Sans TC 由 inertia bundle 自托管--}}
7+
{{-- Google Fonts: Source Sans Pro + Noto Sans TC(與主站 dashboard-v3 對齊;CJK 不進 Vite bundle) --}}
88
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
9+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;700&display=fallback">
910
<title>{{ config('app.name', 'CBDB') }}</title>
1011
<style>
1112
html, body {

resources/views/layouts/dashboard-v3.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
<link rel="icon" type="image/png" sizes="192x192" href="/icon-192.png">
1313
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
1414

15-
<!-- Google Font: Source Sans Pro -->
15+
<!-- Google Fonts: Source Sans Pro + Noto Sans TC(CJK 走 Google Fonts,不進 Vite bundle) -->
1616
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
17+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;700&display=fallback">
1718
<!-- Font Awesome -->
1819
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
1920
<!-- Ionicons -->

0 commit comments

Comments
 (0)