Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ dist
.eslintcache

temp

docs/.vitepress/dist
docs/.vitepress/cache
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img src="./assets/header-illustration.svg" alt="tsdown" width="100%" /><br>
<img src="./docs/public/og-image.svg" alt="tsdown" width="100%" /><br>

# tsdown [![npm](https://img.shields.io/npm/v/tsdown.svg)](https://npmjs.com/package/tsdown) [![Unit Test](https://github.com/rolldown/tsdown/actions/workflows/tests.yml/badge.svg)](https://github.com/rolldown/tsdown/actions/workflows/tests.yml) [![JSR](https://jsr.io/badges/@sxzz/tsdown)](https://jsr.io/@sxzz/tsdown)

Expand Down
1 change: 0 additions & 1 deletion assets/header-illustration.svg

This file was deleted.

1 change: 0 additions & 1 deletion assets/logo.svg

This file was deleted.

39 changes: 39 additions & 0 deletions docs/.vitepress/components/HomePage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script setup lang="ts">
import { useData } from 'vitepress'
import { computed } from 'vue'

const { lang, isDark } = useData()

const voidZeroLogo = computed(() =>
isDark
? 'https://voidzero.dev/logo-white.svg'
: 'https://voidzero.dev/logo.svg',
)
</script>

<template>
<div flex="~ col" items-center justify-center>
<div mt20 flex="~ col" items-center gap8>
<h2 v-if="lang === 'en'" class="voidzero-title">Brought to you by</h2>
<a href="https://voidzero.dev/" target="_blank" title="voidzero.dev">
<img :src="voidZeroLogo" alt="VoidZero" h-75px w-300px />
</a>
<h2 v-if="lang === 'zh-CN'" class="voidzero-title">
由 VoidZero 隆重推出
</h2>
</div>

<img
mt12
src="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.wide.svg"
/>
</div>
</template>

<style scoped>
.voidzero-title {
line-height: 32px;
font-size: 24px;
font-weight: 600;
}
</style>
46 changes: 46 additions & 0 deletions docs/.vitepress/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { defineConfig } from 'vitepress'
import { groupIconMdPlugin } from 'vitepress-plugin-group-icons'
import { getLocaleConfig } from './theme'

// https://vitepress.dev/reference/site-config
export default defineConfig({
locales: {
root: getLocaleConfig('en'),
'zh-CN': getLocaleConfig('zh-CN'),
},

lastUpdated: true,
cleanUrls: true,
themeConfig: {
search: {
provider: 'local',
options: {
locales: {
'zh-CN': {
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档',
},
modal: {
noResultsText: '无法找到相关结果',
resetButtonTitle: '清除查询条件',
footer: {
selectText: '选择',
navigateText: '切换',
closeText: '关闭',
},
},
},
},
},
},
},
},

markdown: {
config(md) {
md.use(groupIconMdPlugin)
},
},
})
148 changes: 148 additions & 0 deletions docs/.vitepress/config/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { createTranslate } from '../i18n/utils'
import type { DefaultTheme, HeadConfig, LocaleConfig } from 'vitepress'

export function getLocaleConfig(lang: string) {
const t = createTranslate(lang)

const urlPrefix = lang && lang !== 'en' ? (`/${lang}` as const) : ''
const title = t('tsdown')
const description = t('The Elegant Bundler for Libraries')
const titleTemplate = `:title - ${description}`

const head: HeadConfig[] = [
[
'link',
{
rel: 'icon',
type: 'image/svg+xml',
href: '/tsdown.svg',
},
],
['meta', { name: 'theme-color', content: '#ff7e17' }],
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:locale', content: 'en' }],
[
'meta',
{
property: 'og:title',
content: `tsdown | ${description}`,
},
],
[
'meta',
{
property: 'og:image',
content: 'https://tsdown.dev/og-image.png',
},
],
['meta', { property: 'og:site_name', content: 'Rolldown' }],
['meta', { property: 'og:url', content: 'https://rolldown.rs/' }],
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['meta', { name: 'twitter:site', content: '@rolldown_rs' }],
]

const nav: DefaultTheme.NavItem[] = [
{ text: t('Home'), link: `${urlPrefix}/` },
{ text: t('Guide'), link: `${urlPrefix}/guide/` },
{
text: t('API Reference'),
link: `${urlPrefix}/reference/config-options.md`,
},
]

const sidebar: DefaultTheme.SidebarItem[] = [
{
base: `${urlPrefix}/guide`,
items: [
{
text: t('Guide'),
items: [
{ text: t('Introduction'), link: '/index.md' },
{ text: t('Getting Started'), link: '/getting-started.md' },
{ text: t('Migrate from tsup'), link: '/migrate-from-tsup.md' },
],
},
{
text: t('Recipes'),
items: [
{ text: t('Entry'), link: '/entry.md' },
{ text: t('Config File'), link: '/config-file.md' },
{ text: t('Declaration Files (dts)'), link: '/dts.md' },
{ text: t('Output Format'), link: '/output-format.md' },
{ text: t('Output Directory'), link: '/output-directory.md' },
{ text: t('Cleaning'), link: '/cleaning.md' },
{ text: t('Watch Mode'), link: '/watch-mode.md' },
{ text: t('Target'), link: '/target.md' },
{ text: t('Platform'), link: '/platform.md' },
{ text: t('Tree-shaking'), link: '/tree-shaking.md' },
{ text: t('Source Maps'), link: '/sourcemap.md' },
{ text: t('Minification'), link: '/minification.md' },
{ text: t('Silent Mode'), link: '/silent-mode.md' },
{ text: t('Shims'), link: '/shims.md' },
],
},
{
text: t('Advanced'),
items: [
{ text: t('Plugins'), link: '/plugins.md' },
{ text: t('Rolldown Options'), link: '/rolldown-options.md' },
],
},
],
},
{
text: t('API Reference'),
base: `${urlPrefix}/reference`,
items: [
{ text: t('Config Options'), link: '/config-options.md' },
{ text: t('Command Line Interface'), link: '/cli.md' },
],
},
]

const themeConfig: DefaultTheme.Config = {
logo: { src: '/tsdown.svg', width: 24, height: 24 },
nav,
sidebar,
outline: 'deep',
socialLinks: [
{ icon: 'github', link: 'https://github.com/rolldown/tsdown' },
{ icon: 'npm', link: 'https://npmjs.com/package/tsdown' },
{ icon: 'jsr', link: 'https://jsr.io/@sxzz/tsdown' },
],
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2025-present VoidZero Inc. & Contributors',
},
}

if (lang === 'zh-CN') {
Object.assign(themeConfig, {
outline: {
label: '页面导航',
level: 'deep',
},
lastUpdatedText: '最后更新于',
darkModeSwitchLabel: '外观',
sidebarMenuLabel: '目录',
returnToTopLabel: '返回顶部',
langMenuLabel: '选择语言',
docFooter: {
prev: '上一页',
next: '下一页',
},
} satisfies DefaultTheme.Config)
}

const localeConfig: LocaleConfig<DefaultTheme.Config>[string] = {
label: t('English'),
lang: t('en'),
title,
titleTemplate,
description,
head,
themeConfig,
}

return localeConfig
}
7 changes: 7 additions & 0 deletions docs/.vitepress/i18n/composable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useData } from 'vitepress'
import { t } from './utils'

export function useTranslate(lang?: string) {
const { lang: vpLang } = useData()
return (key: string) => t(key, lang || vpLang.value)
}
43 changes: 43 additions & 0 deletions docs/.vitepress/i18n/translate-map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export const zhCN = {
// nav
Home: '首页',
Guide: '指南',
'API Reference': 'API 参考',

// sidebar
Introduction: '介绍',
'Getting Started': '快速上手',
'Migrate from tsup': ' 从 tsup 迁移',

Recipes: '实践指南',
Entry: '入口文件',
Cleaning: '清理',
'Config File': '配置文件',
Minification: '压缩',
'Output Directory': '输出目录',
'Output Format': '输出格式',
Platform: '运行平台(Platform)',
'Silent Mode': '静默模式',
'Source Maps': '源映射(Source Maps)',
Target: '构建目标(Target)',
'Tree-shaking': '除屑优化(Tree-shaking)',
'Watch Mode': '监听模式',
Shims: 'Shims(兼容代码)',
'Declaration Files (dts)': '声明文件(dts)',

Advanced: '高级功能',
'Rolldown Options': 'Rolldown 选项',
Plugins: '插件',

'Config Options': '配置选项',
'Command Line Interface': '命令行接口',

'The Elegant Bundler for Libraries': '优雅的库打包器',

English: '简体中文',
en: 'zh-CN',
}

export const translateMap: Record<string, Record<string, string>> = {
'zh-CN': zhCN,
}
9 changes: 9 additions & 0 deletions docs/.vitepress/i18n/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { translateMap } from './translate-map'

export function t(key: string, lang: string) {
return translateMap[lang]?.[key] || key
}

export function createTranslate(lang: string) {
return (key: string) => t(key, lang)
}
57 changes: 57 additions & 0 deletions docs/.vitepress/scripts/docs-generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

safe_sed() {
if [ "$(uname)" = "Darwin" ]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}

echo "📚 Generating reference..."

# Generate API documentation
./node_modules/.bin/typedoc --tsconfig tsconfig.json >/dev/null 2>&1

echo "✅ Reference generated successfully!"

echo "📚 Beautifying reference structure..."

# Move Options.md to ./docs/reference
mv ./docs/reference/api/interfaces/Options.md ./docs/reference/config-options.md

# Remove the type-aliases folder if it exists
if [ -d "./docs/reference/type-aliases" ]; then
rm -rf ./docs/reference/type-aliases
fi
# Create the type-aliases folder
mkdir -p ./docs/reference/type-aliases
# Move types-aliases/Sourcemap.md to ./docs/reference/type-aliases
mv ./docs/reference/api/type-aliases/Sourcemap.md ./docs/reference/type-aliases/Sourcemap.md

# Remove the api folder
rm -rf ./docs/reference/api

# In config-options.md, remove 6 first lines
safe_sed '1,6d' ./docs/reference/config-options.md
# In config-options.md, replace "../type-aliases" with "./type-aliases"
safe_sed 's/..\/type-aliases/.\/type-aliases/g' ./docs/reference/config-options.md

# In type-aliases files, remove 6 first lines
safe_sed '1,6d' ./docs/reference/type-aliases/*.md

# Initialize an array of all locales
locales=("zh-CN")
# Copy the config-options.md file and the type-aliases folder to each locale
for locale in "${locales[@]}"; do
# Copy config-options.md to the locale directory
cp ./docs/reference/config-options.md "./docs/$locale/reference/config-options.md"
# Remove the type-aliases folder if it exists in the locale directory
if [ -d "./docs/$locale/reference/type-aliases" ]; then
rm -rf "./docs/$locale/reference/type-aliases"
fi
# Copy the type-aliases folder to the locale directory
cp -r ./docs/reference/type-aliases "./docs/$locale/reference"
done

echo "✅ Reference structure beautified successfully!"
12 changes: 12 additions & 0 deletions docs/.vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script setup lang="ts">
import DefaultTheme from 'vitepress/theme'
import HomePage from '../components/HomePage.vue'
</script>

<template>
<DefaultTheme.Layout>
<template #home-features-after>
<HomePage />
</template>
</DefaultTheme.Layout>
</template>
Loading