fix(build): respect srcExclude in content loader (#2963)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/2975/head
huluobotx 1 year ago committed by GitHub
parent 3174f2193f
commit 3023b5c76b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -97,6 +97,7 @@ export async function resolveConfig(
const config: SiteConfig = {
root,
srcDir,
srcExclude: userConfig.srcExclude || [],
assetsDir,
site,
themeDir,

@ -106,7 +106,8 @@ export function createContentLoader<T = ContentData[]>(
// the loader is being called directly, do a fresh glob
files = (
await glob(pattern, {
ignore: ['**/node_modules/**', '**/dist/**']
cwd: config.srcDir,
ignore: ['**/node_modules/**', '**/dist/**', ...config.srcExclude]
})
).sort()
}

@ -28,12 +28,6 @@ import { webFontsPlugin } from './plugins/webFontsPlugin'
import { slash, type PageDataPayload } from './shared'
import { deserializeFunctions, serializeFunctions } from './utils/fnSerialize'
declare module 'vite' {
interface UserConfig {
vitepress?: SiteConfig
}
}
const themeRE = /\/\.vitepress\/theme\/index\.(m|c)?(j|t)s$/
const hashRE = /\.(\w+)\.js$/
const staticInjectMarkerRE =

@ -7,7 +7,7 @@ import {
import fs from 'fs-extra'
import c from 'picocolors'
import path from 'path'
import fg from 'fast-glob'
import glob from 'fast-glob'
import { type SiteConfig, type UserConfig } from '../siteConfig'
import { resolveRewrites } from './rewritesPlugin'
@ -21,9 +21,13 @@ export async function resolvePages(srcDir: string, userConfig: UserConfig) {
// JavaScript built-in sort() is mandated to be stable as of ES2019 and
// supported in Node 12+, which is required by Vite.
const allMarkdownFiles = (
await fg(['**.md'], {
await glob(['**.md'], {
cwd: srcDir,
ignore: ['**/node_modules', ...(userConfig.srcExclude || [])]
ignore: [
'**/node_modules/**',
'**/dist/**',
...(userConfig.srcExclude || [])
]
})
).sort()

@ -0,0 +1,7 @@
import 'vite'
declare module 'vite' {
interface UserConfig {
vitepress?: import('./config').SiteConfig
}
}

@ -216,6 +216,7 @@ export interface SiteConfig<ThemeConfig = any>
> {
root: string
srcDir: string
srcExclude: string[]
site: SiteData<ThemeConfig>
configPath: string | undefined
configDeps: string[]

Loading…
Cancel
Save