Skip to content

Commit 60869d3

Browse files
committed
输出字体位置
1 parent bff72e2 commit 60869d3

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ jobs:
5656
echo "📦 Build output directory contents:"
5757
ls -lh dist/ | head -20
5858
echo ""
59-
echo "🔤 Font files:"
60-
ls -lh public/fonts/ 2>/dev/null || echo "No font files found"
59+
echo "🔤 Font files in dist/fonts/:"
60+
ls -lh dist/fonts/ 2>/dev/null || echo "No font files found in dist/fonts/"
61+
echo ""
62+
echo "🔤 Font files in public/fonts/:"
63+
ls -lh public/fonts/ 2>/dev/null || echo "No font files found in public/fonts/"
6164
6265
- name: Deploy to EdgeOne Pages
6366
run: bunx edgeone pages deploy dist -n ${{ secrets.EDGEONE_PROJECT_NAME }} -t ${{ secrets.EDGEONE_API_TOKEN }}

scripts/subset-fonts.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const projectRoot = join(__dirname, '..')
1111
const distDir = join(projectRoot, 'dist')
1212
const fontsSourceDir = join(projectRoot, 'fonts-source')
1313
const fontsOutputDir = join(projectRoot, 'public', 'fonts')
14+
const distFontsDir = join(distDir, 'fonts')
1415

1516
// 思源宋体字体文件路径(支持 TTF 和 OTF)
1617
let sourceFontPath = ''
@@ -177,6 +178,22 @@ function generateFontSubset(characters) {
177178
const sizeMB = (stats.size / 1024 / 1024).toFixed(2)
178179
console.log(`📦 文件大小: ${sizeKB} KB (${sizeMB} MB)`)
179180

181+
// 复制字体文件到 dist/fonts/ 目录(构建后生成的文件需要手动复制)
182+
if (!fs.existsSync(distFontsDir)) {
183+
fs.mkdirSync(distFontsDir, { recursive: true })
184+
}
185+
const distFontPath = join(distFontsDir, 'NotoSerifCJK-Subset.woff2')
186+
copyFileSync(outputFontPath, distFontPath)
187+
console.log(`📋 字体文件已复制到: ${distFontPath}`)
188+
189+
// 同时复制 LinBiolinum.woff2(如果存在)
190+
const linBiolinumPath = join(fontsOutputDir, 'LinBiolinum.woff2')
191+
if (fs.existsSync(linBiolinumPath)) {
192+
const distLinBiolinumPath = join(distFontsDir, 'LinBiolinum.woff2')
193+
copyFileSync(linBiolinumPath, distLinBiolinumPath)
194+
console.log(`📋 LinBiolinum 字体已复制到: ${distLinBiolinumPath}`)
195+
}
196+
180197
resolve()
181198
})
182199

0 commit comments

Comments
 (0)