fix(www): enable font content hashing and automated preloads (#68)

🤖 **Summary:**
- **Root cause:** Font static assets were configured with unhashed
filenames (`[name][ext]`) while served with `Cache-Control: immutable,
max-age=31536000`. This caused Cloudflare edge nodes and client browsers
to permanently cache the older Latin-only font files from Sept 2026
under `https://www.ermnvldmr.com/ru/static/font/lato-400.woff2`,
ignoring the updated Cyrillic glyphs.
- **Changes:**
- Removed explicit `filename: { font: '[name][ext]' }` in
`packages/rsbuild-config/src/lib/config/rsbuild.ts` to enable Rsbuild's
default content-hashed font filenames (`[name].[contenthash:8][ext]`).
- Updated `services/www/rsbuild.config.ts` to remove hardcoded unhashed
font preload tags and configure Rsbuild's `performance.preload` to
automatically discover and emit hashed font `<link rel="preload"
as="font" crossorigin>` tags.
This commit is contained in:
deytenit authored and GitHub committed 2026-10-25 21:15:04 +03:00
1 parent 9a175925b6
commit 24f3311006
2 files changed
+6 -38

No files matched your search

@@ -26,9 +26,6 @@ export function defineServiceConfig(config: RsbuildConfig = {}): RsbuildConfig {
distPath: {
font: 'static/font',
},
filename: {
font: '[name][ext]',
},
},
html: {
template: './src/static/index.html',
+6 -35
View File
@@ -34,8 +34,6 @@ const MIME: Record<string, string> = {
};
const UMAMI_WWW_WEBSITE_ID = '4fca5ac2-4fe4-4626-b708-933c37bfe918';
const locale = process.env.LOCALE ?? 'en';
const fontBase = `/${locale}/static/font`;
export default defineSSGServiceConfig(
mergeConfig(localeRsbuildConfig(), {
@@ -99,44 +97,17 @@ export default defineSSGServiceConfig(
entry: discoverEntries(import.meta.dirname, './src/app/**/*.tsx'),
preEntry: ['./src/static/global.css'],
},
performance: {
preload: {
type: 'all-assets',
include: [/(lato-400|lato-700|eb-garamond-var)\..*\.woff2$/],
},
},
html: {
tags: [
{ tag: 'script', children: TRUSTED_TYPES_INIT_SCRIPT, head: true },
{ tag: 'script', children: THEME_INIT_SCRIPT, head: true },
{ tag: 'style', children: THEME_INIT_STYLES, head: true },
{
tag: 'link',
attrs: {
rel: 'preload',
as: 'font',
type: 'font/woff2',
href: `${fontBase}/lato-400.woff2`,
crossorigin: true,
},
publicPath: false,
},
{
tag: 'link',
attrs: {
rel: 'preload',
as: 'font',
type: 'font/woff2',
href: `${fontBase}/lato-700.woff2`,
crossorigin: true,
},
publicPath: false,
},
{
tag: 'link',
attrs: {
rel: 'preload',
as: 'font',
type: 'font/woff2',
href: `${fontBase}/eb-garamond-var.woff2`,
crossorigin: true,
},
publicPath: false,
},
],
},
})