From 119473921b1230bb842aebe9ef86bf75a3f6a62d Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Wed, 20 Sep 2023 15:18:53 -0500 Subject: [PATCH] hack: filter content collection glob --- .../vite-plugin-content-virtual-mod.ts | 20 +++++++++++-------- packages/astro/src/core/build/static-build.ts | 3 +-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts index d7924973c..0ea58a545 100644 --- a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts +++ b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts @@ -37,6 +37,15 @@ export function astroContentVirtualModPlugin({ const contentEntryExts = [...contentEntryConfigByExt.keys()]; const dataEntryExts = getDataEntryExts(settings); + let contentEntryGlobPath = globWithUnderscoresIgnored(relContentDir, contentEntryExts); + // HACK(nate): filter contentEntryGlobPath to simulate incremental build + contentEntryGlobPath = [contentEntryGlobPath[0].replace('**/*', '**/a-e*')] + + const dataEntryGlobPath = globWithUnderscoresIgnored(relContentDir, dataEntryExts); + /** Note: data collections excluded */ + let renderEntryGlobPath = globWithUnderscoresIgnored(relContentDir, contentEntryExts); + renderEntryGlobPath = [renderEntryGlobPath[0].replace('**/*', '**/a-e*')] + const virtualModContents = fsMod .readFileSync(contentPaths.virtualModTemplate, 'utf-8') .replace( @@ -46,20 +55,15 @@ export function astroContentVirtualModPlugin({ .replace('@@CONTENT_DIR@@', relContentDir) .replace( "'@@CONTENT_ENTRY_GLOB_PATH@@'", - JSON.stringify(globWithUnderscoresIgnored(relContentDir, contentEntryExts)) + JSON.stringify(contentEntryGlobPath) ) .replace( "'@@DATA_ENTRY_GLOB_PATH@@'", - JSON.stringify(globWithUnderscoresIgnored(relContentDir, dataEntryExts)) + JSON.stringify(dataEntryGlobPath) ) .replace( "'@@RENDER_ENTRY_GLOB_PATH@@'", - JSON.stringify( - globWithUnderscoresIgnored( - relContentDir, - /** Note: data collections excluded */ contentEntryExts - ) - ) + JSON.stringify(renderEntryGlobPath) ); const astroContentVirtualModuleId = '\0' + VIRTUAL_MODULE_ID; diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index ee657f2df..7b0d6e378 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -97,7 +97,6 @@ export async function viteBuild(opts: StaticBuildOptions) { for (const output of ssrOutput.output) { const md = output.moduleIds.filter(id => id.endsWith('.md')) if (!!md) { - console.log(output.moduleIds); // const { fileName: id, code: content } = output.moduleIds // internals.cache.push({ input, output: { id, content } }) } @@ -106,7 +105,7 @@ export async function viteBuild(opts: StaticBuildOptions) { fs.writeFileSync(cacheFile, JSON.stringify(internals.cache), { encoding: 'utf8' }); if (restore) { - console.log('RESTORING CACHE'); + // console.log('RESTORING CACHE'); for (const cached of internals.cache) { fs.writeFileSync(new URL(`./${cached.output.id}`, settings.config.outDir), cached.output.content, { encoding: 'utf8' }); }