feat(build): support `cacheDir` (#1355)

pull/1677/merge
Shigma 2 years ago committed by GitHub
parent 6b4b31d9b4
commit f899764bad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -198,6 +198,19 @@ export default {
}
```
## cacheDir
- Type: `string`
- Default: `./.vitepress/cache`
The directory for cache files, relative to project root (`docs` folder if you're running `vitepress build docs`). See also: [cacheDir](https://vitejs.dev/config/shared-options.html#cachedir).
```ts
export default {
outDir: './.vitepress/.vite'
}
```
## srcDir
- Type: `string`

@ -14,6 +14,7 @@ export async function buildMPAClient(
return build({
root: config.srcDir,
cacheDir: config.cacheDir,
base: config.site.base,
logLevel: 'warn',
build: {

@ -41,6 +41,7 @@ export async function bundle(
const resolveViteConfig = async (ssr: boolean): Promise<ViteUserConfig> => ({
root: config.srcDir,
cacheDir: config.cacheDir,
base: config.site.base,
logLevel: 'warn',
plugins: await createVitePressPlugin(

@ -53,6 +53,7 @@ export interface UserConfig<ThemeConfig = any> {
srcDir?: string
srcExclude?: string[]
outDir?: string
cacheDir?: string
shouldPreload?: (link: string, page: string) => boolean
/**
@ -165,6 +166,7 @@ export interface SiteConfig<ThemeConfig = any>
configDeps: string[]
themeDir: string
outDir: string
cacheDir: string
tempDir: string
pages: string[]
}
@ -203,6 +205,9 @@ export async function resolveConfig(
const outDir = userConfig.outDir
? path.resolve(root, userConfig.outDir)
: resolve(root, 'dist')
const cacheDir = userConfig.cacheDir
? path.resolve(root, userConfig.cacheDir)
: resolve(root, 'cache')
// resolve theme path
const userThemeDir = resolve(root, 'theme')
@ -232,6 +237,7 @@ export async function resolveConfig(
configPath,
configDeps,
outDir,
cacheDir,
tempDir: resolve(root, '.temp'),
markdown: userConfig.markdown,
lastUpdated: userConfig.lastUpdated,

@ -20,6 +20,7 @@ export async function createServer(
return createViteServer({
root: config.srcDir,
base: config.site.base,
cacheDir: config.cacheDir,
// logLevel: 'warn',
plugins: await createVitePressPlugin(config, false, {}, {}, recreateServer),
server: serverOptions

Loading…
Cancel
Save