Skip to content

Commit 16a0ff8

Browse files
Sepushbrc-dd
andauthored
chore: use rolldown-vite (#4769)
--------- Signed-off-by: Artea <sepush@outlook.com> Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
1 parent e7f9d05 commit 16a0ff8

File tree

14 files changed

+1080
-1174
lines changed

14 files changed

+1080
-1174
lines changed

docs/.vitepress/config.ts

Lines changed: 142 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
defineConfig,
33
resolveSiteDataByRoute,
4+
type ConfigEnv,
45
type HeadConfig
56
} from 'vitepress'
67
import {
@@ -12,137 +13,160 @@ import llmstxt from 'vitepress-plugin-llms'
1213

1314
const prod = !!process.env.NETLIFY
1415

15-
export default defineConfig({
16-
title: 'VitePress',
16+
export default (ctx: ConfigEnv) =>
17+
defineConfig({
18+
title: 'VitePress',
1719

18-
rewrites: {
19-
'en/:rest*': ':rest*'
20-
},
20+
rewrites: {
21+
'en/:rest*': ':rest*'
22+
},
2123

22-
lastUpdated: true,
23-
cleanUrls: true,
24-
metaChunk: true,
24+
lastUpdated: true,
25+
cleanUrls: true,
26+
metaChunk: true,
2527

26-
markdown: {
27-
math: true,
28-
codeTransformers: [
29-
// We use `[!!code` in demo to prevent transformation, here we revert it back.
30-
{
31-
postprocess(code) {
32-
return code.replace(/\[\!\!code/g, '[!code')
28+
markdown: {
29+
math: true,
30+
codeTransformers: [
31+
// We use `[!!code` in demo to prevent transformation, here we revert it back.
32+
{
33+
postprocess(code) {
34+
return code.replace(/\[\!\!code/g, '[!code')
35+
}
36+
}
37+
],
38+
config(md) {
39+
// TODO: remove when https://github.com/vuejs/vitepress/issues/4431 is fixed
40+
const fence = md.renderer.rules.fence!
41+
md.renderer.rules.fence = function (tokens, idx, options, env, self) {
42+
const { localeIndex = 'root' } = env
43+
const codeCopyButtonTitle = (() => {
44+
switch (localeIndex) {
45+
case 'es':
46+
return 'Copiar código'
47+
case 'fa':
48+
return 'کپی کد'
49+
case 'ko':
50+
return '코드 복사'
51+
case 'pt':
52+
return 'Copiar código'
53+
case 'ru':
54+
return 'Скопировать код'
55+
case 'zh':
56+
return '复制代码'
57+
default:
58+
return 'Copy code'
59+
}
60+
})()
61+
return fence(tokens, idx, options, env, self).replace(
62+
'<button title="Copy Code" class="copy"></button>',
63+
`<button title="${codeCopyButtonTitle}" class="copy"></button>`
64+
)
3365
}
66+
md.use(groupIconMdPlugin)
3467
}
35-
],
36-
config(md) {
37-
// TODO: remove when https://github.com/vuejs/vitepress/issues/4431 is fixed
38-
const fence = md.renderer.rules.fence!
39-
md.renderer.rules.fence = function (tokens, idx, options, env, self) {
40-
const { localeIndex = 'root' } = env
41-
const codeCopyButtonTitle = (() => {
42-
switch (localeIndex) {
43-
case 'es':
44-
return 'Copiar código'
45-
case 'fa':
46-
return 'کپی کد'
47-
case 'ko':
48-
return '코드 복사'
49-
case 'pt':
50-
return 'Copiar código'
51-
case 'ru':
52-
return 'Скопировать код'
53-
case 'zh':
54-
return '复制代码'
55-
default:
56-
return 'Copy code'
57-
}
58-
})()
59-
return fence(tokens, idx, options, env, self).replace(
60-
'<button title="Copy Code" class="copy"></button>',
61-
`<button title="${codeCopyButtonTitle}" class="copy"></button>`
62-
)
68+
},
69+
70+
sitemap: {
71+
hostname: 'https://vitepress.dev',
72+
transformItems(items) {
73+
return items.filter((item) => !item.url.includes('migration'))
6374
}
64-
md.use(groupIconMdPlugin)
65-
}
66-
},
75+
},
6776

68-
sitemap: {
69-
hostname: 'https://vitepress.dev',
70-
transformItems(items) {
71-
return items.filter((item) => !item.url.includes('migration'))
72-
}
73-
},
77+
head: [
78+
[
79+
'link',
80+
{ rel: 'icon', type: 'image/svg+xml', href: '/vitepress-logo-mini.svg' }
81+
],
82+
[
83+
'link',
84+
{ rel: 'icon', type: 'image/png', href: '/vitepress-logo-mini.png' }
85+
],
86+
['meta', { name: 'theme-color', content: '#5f67ee' }],
87+
['meta', { property: 'og:type', content: 'website' }],
88+
['meta', { property: 'og:site_name', content: 'VitePress' }],
89+
[
90+
'meta',
91+
{
92+
property: 'og:image',
93+
content: 'https://vitepress.dev/vitepress-og.jpg'
94+
}
95+
],
96+
['meta', { property: 'og:url', content: 'https://vitepress.dev/' }],
97+
[
98+
'script',
99+
{
100+
src: 'https://cdn.usefathom.com/script.js',
101+
'data-site': 'AZBRSFGG',
102+
'data-spa': 'auto',
103+
defer: ''
104+
}
105+
]
106+
],
74107

75-
/* prettier-ignore */
76-
head: [
77-
['link', { rel: 'icon', type: 'image/svg+xml', href: '/vitepress-logo-mini.svg' }],
78-
['link', { rel: 'icon', type: 'image/png', href: '/vitepress-logo-mini.png' }],
79-
['meta', { name: 'theme-color', content: '#5f67ee' }],
80-
['meta', { property: 'og:type', content: 'website' }],
81-
['meta', { property: 'og:site_name', content: 'VitePress' }],
82-
['meta', { property: 'og:image', content: 'https://vitepress.dev/vitepress-og.jpg' }],
83-
['meta', { property: 'og:url', content: 'https://vitepress.dev/' }],
84-
['script', { src: 'https://cdn.usefathom.com/script.js', 'data-site': 'AZBRSFGG', 'data-spa': 'auto', defer: '' }]
85-
],
108+
themeConfig: {
109+
logo: { src: '/vitepress-logo-mini.svg', width: 24, height: 24 },
86110

87-
themeConfig: {
88-
logo: { src: '/vitepress-logo-mini.svg', width: 24, height: 24 },
111+
socialLinks: [
112+
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
113+
],
89114

90-
socialLinks: [
91-
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
92-
],
115+
search: {
116+
provider: 'algolia',
117+
options: {
118+
appId: '8J64VVRP8K',
119+
apiKey: '52f578a92b88ad6abde815aae2b0ad7c',
120+
indexName: 'vitepress'
121+
}
122+
},
93123

94-
search: {
95-
provider: 'algolia',
96-
options: {
97-
appId: '8J64VVRP8K',
98-
apiKey: '52f578a92b88ad6abde815aae2b0ad7c',
99-
indexName: 'vitepress'
100-
}
124+
carbonAds: { code: 'CEBDT27Y', placement: 'vuejsorg' }
101125
},
102126

103-
carbonAds: { code: 'CEBDT27Y', placement: 'vuejsorg' }
104-
},
127+
locales: {
128+
root: { label: 'English' },
129+
zh: { label: '简体中文' },
130+
pt: { label: 'Português' },
131+
ru: { label: 'Русский' },
132+
es: { label: 'Español' },
133+
ko: { label: '한국어' },
134+
fa: { label: 'فارسی' }
135+
},
105136

106-
locales: {
107-
root: { label: 'English' },
108-
zh: { label: '简体中文' },
109-
pt: { label: 'Português' },
110-
ru: { label: 'Русский' },
111-
es: { label: 'Español' },
112-
ko: { label: '한국어' },
113-
fa: { label: 'فارسی' }
114-
},
137+
vite: {
138+
plugins: [
139+
groupIconVitePlugin({
140+
customIcon: {
141+
vitepress: localIconLoader(
142+
import.meta.url,
143+
'../public/vitepress-logo-mini.svg'
144+
),
145+
firebase: 'logos:firebase'
146+
}
147+
}),
148+
prod &&
149+
llmstxt({
150+
workDir: 'en',
151+
ignoreFiles: ['index.md']
152+
})
153+
],
154+
experimental: {
155+
enableNativePlugin: ctx.command === 'build'
156+
}
157+
},
115158

116-
vite: {
117-
plugins: [
118-
groupIconVitePlugin({
119-
customIcon: {
120-
vitepress: localIconLoader(
121-
import.meta.url,
122-
'../public/vitepress-logo-mini.svg'
123-
),
124-
firebase: 'logos:firebase'
159+
transformPageData: prod
160+
? (pageData, ctx) => {
161+
const site = resolveSiteDataByRoute(
162+
ctx.siteConfig.site,
163+
pageData.relativePath
164+
)
165+
const title = `${pageData.title || site.title} | ${pageData.description || site.description}`
166+
;((pageData.frontmatter.head ??= []) as HeadConfig[]).push(
167+
['meta', { property: 'og:locale', content: site.lang }],
168+
['meta', { property: 'og:title', content: title }]
169+
)
125170
}
126-
}),
127-
prod &&
128-
llmstxt({
129-
workDir: 'en',
130-
ignoreFiles: ['index.md']
131-
})
132-
]
133-
},
134-
135-
transformPageData: prod
136-
? (pageData, ctx) => {
137-
const site = resolveSiteDataByRoute(
138-
ctx.siteConfig.site,
139-
pageData.relativePath
140-
)
141-
const title = `${pageData.title || site.title} | ${pageData.description || site.description}`
142-
;((pageData.frontmatter.head ??= []) as HeadConfig[]).push(
143-
['meta', { property: 'og:locale', content: site.lang }],
144-
['meta', { property: 'og:title', content: title }]
145-
)
146-
}
147-
: undefined
148-
})
171+
: undefined
172+
})

docs/en/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ vitepress build [root]
4343
| `--base <path>` | Public base path (default: `/`) (`string`) |
4444
| `--target <target>` | Transpile target (default: `"modules"`) (`string`) |
4545
| `--outDir <dir>` | Output directory relative to **cwd** (default: `<root>/.vitepress/dist`) (`string`) |
46-
| `--minify [minifier]` | Enable/disable minification, or specify minifier to use (default: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
4746
| `--assetsInlineLimit <number>` | Static asset base64 inline threshold in bytes (default: `4096`) (`number`) |
4847

4948
## `vitepress preview`

docs/es/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ vitepress build [root]
4343
| `--base <path>` | Ruta de base pública (por defecto: `/`) (`string`) |
4444
| `--target <target>` | Transpilar objetivo (por defecto: `"modules"`) (`string`) |
4545
| `--outDir <dir>` | Directorio de salida relativo a **cwd** (por defecto: `<root>/.vitepress/dist`) (`string`) |
46-
| `--minify [minifier]` | Habilitar/desabilitar la minificación, o especifica un minero para usar (por defecto: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
4746
| `--assetsInlineLimit <number>` | Limitar los bytes para alinear los activos en base 64 (por defecto: `4096`) (`number`) |
4847

4948
## `vitepress preview`

docs/fa/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ vitepress build [root]
4343
| `--base <path>` | مسیر پایه عمومی (پیش‌فرض: `/`) (`string`) |
4444
| `--target <target>` | هدف ترنسپایل (پیش‌فرض: `"modules"`) (`string`) |
4545
| `--outDir <dir>` | دایرکتوری خروجی نسبت به **cwd** (پیش‌فرض: `<root>/.vitepress/dist`) (`string`) |
46-
| `--minify [minifier]` | فعال یا غیرفعال کردن فشرده‌سازی، یا تعیین فشرده‌سازی برای استفاده (پیش‌فرض: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
4746
| `--assetsInlineLimit <number>` | آستانه تبدیل پایه ۶۴ استاتیک به بایت (پیش‌فرض: `4096`) (`number`) |
4847

4948
## `vitepress preview` {#vitepress-preview}

docs/ko/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ vitepress build [root]
4343
| `--base <path>` | Public 기본 경로 (기본값: `/`) (`string`) |
4444
| `--target <target>` | 트랜스파일 대상 (기본값: `"modules"`) (`string`) |
4545
| `--outDir <dir>` | **cwd** 기준 출력 디렉터리 (기본값: `<root>/.vitepress/dist`) (`string`) |
46-
| `--minify [minifier]` | minify 활성화/비활성화 또는 사용할 minify 도구 지정 (기본값: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
4746
| `--assetsInlineLimit <number>`| 바이트 단위의 정적 에셋 base64 인라인 임계값 (기본값: `4096`) (`number`) |
4847

4948
## `vitepress preview`

docs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"@lunariajs/core": "^0.1.1",
1414
"markdown-it-mathjax3": "^4.3.2",
1515
"open-cli": "^8.0.0",
16-
"postcss-rtlcss": "^5.7.0",
16+
"postcss-rtlcss": "^5.7.1",
1717
"vitepress": "workspace:*",
18-
"vitepress-plugin-group-icons": "^1.5.2",
19-
"vitepress-plugin-llms": "^1.1.3"
18+
"vitepress-plugin-group-icons": "^1.5.5",
19+
"vitepress-plugin-llms": "^1.3.4"
2020
}
2121
}

docs/pt/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ vitepress build [root]
4343
| `--base <path>` | Caminho base público (padrão: `/`) (`string`) |
4444
| `--target <target>` | Transpila o alvo (padrão: `"modules"`) (`string`) |
4545
| `--outDir <dir>` | Diretório de saída relativo ao **cwd** (padrão: `<root>/.vitepress/dist`) (`string`) |
46-
| `--minify [minifier]` | Habilita/desabilita minificação, ou especifica um minificador para usar (padrão: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
4746
| `--assetsInlineLimit <number>` | Limite em bytes para alinhar ativos em base64 (padrão: `4096`) (`number`) |
4847

4948
## `vitepress preview`

docs/ru/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ vitepress build [root]
4343
| `--base <path>` | Публичный базовый путь (по умолчанию: `/`) (`string`) |
4444
| `--target <target>` | Транспилировать цель (по умолчанию: `"modules"`) (`string`) |
4545
| `--outDir <dir>` | Выходной каталог относительно **cwd** (по умолчанию: `<root>/.vitepress/dist`) (`string`) |
46-
| `--minify [minifier]` | Включить/выключить минификацию или задать используемый минификатор (по умолчанию: `"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
4746
| `--assetsInlineLimit <number>` | Статический встроенный порог ресурса base64 в байтах (по умолчанию: `4096`) (`number`) |
4847

4948
## `vitepress preview` {#vitepress-preview}

docs/zh/reference/cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ vitepress build [root]
4343
| `--base <path>` | public base URL (默认值: `/`) (`string`) |
4444
| `--target <target>` | 转译目标 (默认值:`"modules"`) (`string`) |
4545
| `--outDir <dir>` | 输出目录 (默认值:`.vitepress/dist`) (`string`) |
46-
| `--minify [minifier]` | 启用/禁用压缩,或指定要使用的压缩程序 (默认值:`"esbuild"`) (`boolean \| "terser" \| "esbuild"`) |
4746
| `--assetsInlineLimit <number>` | 静态资源 base64 内联阈值(以字节为单位)(默认值:`4096`) (`number`) |
4847

4948
## `vitepress preview`

0 commit comments

Comments
 (0)