1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-04-28 20:50:44 +08:00
Files
408CSFamily/vuepress.config.ts
公众号:Rong姐姐好可爱 779994121d feat: 升级vuepress到最新版本,改造整个项目结构、配置 (#108)
* feat: 升级`vuepress`到最新版本,改造整个项目结构、配置

* chore: update

* chore: update

* fix: update
2024-09-26 12:05:53 +08:00

69 lines
1.8 KiB
TypeScript
Raw 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'
import process from 'node:process'
import { defineUserConfig } from '@vuepress/cli'
import { path } from '@vuepress/utils'
import viteBundler from '@vuepress/bundler-vite'
import { name } from './package.json'
import themeConfig from './docs/.vuepress/theme/theme'
import { headers } from './docs/.vuepress/theme/headers'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
/**
* 用于区分base路径是否nginx代理
*/
function getSiteBase(): '/' | `/${string}/` {
// 用于区分base路径是否nginx代理
const needProxy = process.env.NEED_PROXY || false
return needProxy ? `/${name}/` : '/'
}
/**
* 用户自定义配置
* 注意:
* - 环境变量中的PROXY_DOMAIN字段用于区分是否nginx代理
*/
export default defineUserConfig({
title: '计算机408全家桶',
description: '磨刀不误砍柴工,读完硕士再打工',
// 用于区分base路径是否nginx代理
base: getSiteBase(),
port: 4200,
source: '',
head: headers,
markdown: {
// todo 引入代码文件时的路径替换
importCode: {
handleImportPath: (str) => {
if (str.includes('@code')) {
return str.replace(/^@code/, path.resolve(__dirname, '../../code/'))
}
if (str.includes('@ds')) {
return str.replace(/^@ds/, path.resolve(__dirname, '../../code/ds/'))
}
if (str.includes('~')) {
return str.replace(/^~/, path.resolve(__dirname, '../../'))
}
return str
},
},
// md doc formatter headerDepth
headers: {
level: [2, 3, 4],
},
},
// 主题配置
...themeConfig,
// 插件配置
// ...pluginsConfig,
bundler: viteBundler({
viteOptions: {
build: {
chunkSizeWarningLimit: 4096,
},
},
vuePluginOptions: {},
}),
shouldPrefetch: false,
})