From 77971eec8e081e258136be4fd1d1410e91439495 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Thu, 8 Jun 2023 11:10:10 -0400 Subject: [PATCH] fix: experimentalAssetsConfig missing --- .../markdoc/src/vite-plugin-config.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/integrations/markdoc/src/vite-plugin-config.ts b/packages/integrations/markdoc/src/vite-plugin-config.ts index 58d920fff..4bf7e7991 100644 --- a/packages/integrations/markdoc/src/vite-plugin-config.ts +++ b/packages/integrations/markdoc/src/vite-plugin-config.ts @@ -22,9 +22,22 @@ export function vitePluginMarkdocConfig({ astroConfig }: { astroConfig: AstroCon // TODO: invalidate on change const markdocConfigResult = await loadMarkdocConfig(astroConfig); + // Only add `astro/assets` import when `experimental.assets` is enabled. Would throw without this check! + const injectAssetsConfig = astroConfig.experimental.assets; if (!markdocConfigResult) { - return `export default {}`; + return `${ + injectAssetsConfig + ? `import { experimentalAssetsConfig } from '@astrojs/markdoc/experimental-assets-config';\n` + : '' + }export async function getConfig(configOverrides = {}) { return ${ + injectAssetsConfig + ? '{ ...experimentalAssetsConfig, ...configOverrides }' + : 'configOverrides' + } } + export function getConfigSync() { return ${ + injectAssetsConfig ? 'experimentalAssetsConfig' : '{}' + } }`; } const { config: unresolvedConfig, fileUrl } = markdocConfigResult; const config = await setupConfig(unresolvedConfig);