Files
2026-10-08 17:32:12 +08:00

55 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { fileURLToPath } from 'node:url'
/**
* 文档站(Docus)。
*
* 几个刻意的选择:
* - extends: ['docus'] —— Docus 是 Nuxt Layer,全部能力(导航、搜索、主题)由它提供
* - alias 直连 packages 源码 —— 组件库尚未构建也能开发,改组件即时热更
* (tokens 例外:它是 SCSS 编译产物,alias 指向 dist/index.css,需先 build tokens)
*
* 部署到子路径时用环境变量 NUXT_APP_BASE_URL=/docs/,不在配置里写死。
*/
export default defineNuxtConfig({
extends: ['docus'],
// sitemap.xml、llms.txt、OG image 都依赖站点 URL,缺了会导致预渲染 500
site: {
url: process.env.DOCS_SITE_URL || 'https://ui.g3soft.dev',
name: 'G3Soft 技术文档',
},
// 监听所有网卡:控制台会打印可用的 Local(http://localhost:PORT) 与 Network(局域网地址)。
// 这里必须用空串而不是 '0.0.0.0':listhen 把空串当“全部网卡”,且生成 URL 时回退成 localhost;
// 而 '0.0.0.0' 会把 Local 那行显示成 http://0.0.0.0:PORT(浏览器打不开)。
devServer: {
host: '',
},
vite: {
resolve: {
// 用正则做“精确匹配”:否则 '@g3soft/tokens' 的前缀别名会把
// '@g3soft/tokens/scss' 也一并改写掉,导致组件里的 @use 找不到 SCSS。
alias: [
{
find: /^@g3soft\/ui$/,
replacement: fileURLToPath(new URL('../packages/ui/src/index.ts', import.meta.url)),
},
{
// tokens 是 SCSS 编译产物:仅裸导入指向 dist/index.css(由 @g3soft/tokens 的 build 生成)
find: /^@g3soft\/tokens$/,
replacement: fileURLToPath(
new URL('../packages/tokens/dist/index.css', import.meta.url),
),
},
],
},
server: {
fs: {
// 组件库源码在 docs 目录之外,需要放开读取范围
allow: [fileURLToPath(new URL('..', import.meta.url))],
},
},
},
})