Files
ermnvldmr.com/services/www/rsbuild.config.ts
T
deytenit cd40139eea fix(www): resolve SSG build issues with font preloads, dark theme and… (#7)
… RU locale

- Fix depth-dependent duplicate font preload prefixes by using
locale-absolute fontBase path and publicPath:false on html.tags to
prevent Rsbuild from re-applying assetPrefix (path.posix.join behavior
with MPA nested entries)
- Fix .dark CSS rule stripped by critters: set reduceInlineStyles:false
so critters only processes external stylesheets and leaves inline theme
init styles (THEME_INIT_STYLES) intact
- Fix NormalModuleReplacementPlugin lost in mergeConfig: refactored
locale MDX replacement from tools.rspack function into a proper Rsbuild
plugin so mergeConfig concatenates plugin arrays correctly (enables RU
locale articles)
- Extend Critters type declaration to include reduceInlineStyles option

Made-with: Cursor
2026-03-16 01:27:42 +03:00

76 lines
2.1 KiB
TypeScript

import { defineServiceConfig, discoverEntries, mergeConfig } from '@ermnvldmr/rsbuild-config/dev';
import { THEME_INIT_SCRIPT, THEME_INIT_STYLES } from '@ermnvldmr/ui/dev';
import { localeRsbuildConfig } from '@ermnvldmr/i18n/dev';
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
import { pluginMdx } from '@rsbuild/plugin-mdx';
import remarkFrontmatter from 'remark-frontmatter';
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
const locale = process.env.LOCALE ?? 'en';
const fontBase = `/${locale}/static/font`;
export default defineServiceConfig(
mergeConfig(localeRsbuildConfig(), {
tools: {
rspack: {
plugins: [
process.env.RSDOCTOR === 'true' &&
new RsdoctorRspackPlugin({
disableClientServer: true,
output: { reportDir: './rsdoctor', mode: 'brief' },
}),
].filter(Boolean),
},
},
plugins: [
pluginMdx({
mdxLoaderOptions: {
remarkPlugins: [remarkFrontmatter, [remarkMdxFrontmatter, { name: 'frontmatter' }]],
},
}),
],
source: {
entry: discoverEntries(import.meta.dirname, './src/app/**/*.tsx'),
},
html: {
tags: [
{ 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,
},
],
},
})
);