fix: make paths in `watchedFiles` absolute as mentioned in the docs

pull/4898/merge
Divyansh Singh 1 month ago
parent 777e2caaac
commit 318c14fa7c

@ -6,7 +6,7 @@ export default defineRoutes({
// console.log('watchedFiles', watchedFiles)
return paths
},
watch: ['**/data-loading/**/*.json'],
watch: ['../data-loading/**/*.json'],
async transformPageData(pageData) {
// console.log('transformPageData', pageData.filePath)
pageData.title += ' - transformed'

@ -95,7 +95,10 @@ export function createContentLoader<T = ContentData[]>(
async load(files?: string[]) {
// the loader is being called directly, do a fresh glob
files = files ?? (await glob(watch, options.globOptions))
files ??= await glob(watch, {
absolute: true,
...options.globOptions
})
const md = await createMarkdownRenderer(
config.srcDir,

@ -308,7 +308,10 @@ async function resolveDynamicRoutes(
let pathsData: UserRouteConfig[]
if (typeof loader === 'function') {
const watchedFiles = await glob(watch, options.globOptions)
const watchedFiles = await glob(watch, {
absolute: true,
...options.globOptions
})
pathsData = await loader(watchedFiles)
} else {
pathsData = loader

@ -97,7 +97,10 @@ export const staticDataPlugin: Plugin = {
}
// load the data
const watchedFiles = await glob(watch, options.globOptions)
const watchedFiles = await glob(watch, {
absolute: true,
...options.globOptions
})
const data = await load(watchedFiles)
// record loader module for HMR

@ -3,6 +3,7 @@ import { glob as _glob } from 'tinyglobby'
import { normalizePath } from 'vite'
export interface GlobOptions {
absolute?: boolean
cwd?: string
ignore?: string | string[]
dot?: boolean

Loading…
Cancel
Save