diff --git a/packages/zudoku/src/config/loader.ts b/packages/zudoku/src/config/loader.ts index e5e2f1a8..3d0aa7eb 100644 --- a/packages/zudoku/src/config/loader.ts +++ b/packages/zudoku/src/config/loader.ts @@ -3,6 +3,7 @@ import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; import { RollupOutput, RollupWatcher } from "rollup"; import { tsImport } from "tsx/esm/api"; +import { withZuplo } from "../zuplo/with-zuplo.js"; import { ConfigWithMeta } from "./common.js"; import { CommonConfig, validateCommonConfig } from "./validators/common.js"; import { validateConfig } from "./validators/validate.js"; @@ -117,6 +118,9 @@ async function loadDevPortalConfig( // 2. Replace $env() placeholders with actual environment config = replaceEnvVariables(config, envVars); + // 3. Add Zuplo to the config + config = withZuplo(config); + return config; } diff --git a/packages/zudoku/src/config/validators/common.ts b/packages/zudoku/src/config/validators/common.ts index 4e984eff..bee3a5f5 100644 --- a/packages/zudoku/src/config/validators/common.ts +++ b/packages/zudoku/src/config/validators/common.ts @@ -315,6 +315,7 @@ export const CommonConfigSchema = z.object({ apiKeys: ApiKeysSchema, redirects: z.array(Redirect), sitemap: SiteMapSchema, + isZuplo: z.boolean().optional(), }); export const refine = ( diff --git a/packages/zudoku/src/vite/plugin-api.ts b/packages/zudoku/src/vite/plugin-api.ts index acf00b1c..b5c46a22 100644 --- a/packages/zudoku/src/vite/plugin-api.ts +++ b/packages/zudoku/src/vite/plugin-api.ts @@ -1,7 +1,7 @@ import fs from "node:fs/promises"; import path from "node:path"; -import { tsImport } from "tsx/esm/api"; import hashit from "object-hash"; +import { tsImport } from "tsx/esm/api"; import { type Plugin } from "vite"; import yaml from "yaml"; import { type ZudokuPluginOptions } from "../config/config.js"; @@ -10,7 +10,6 @@ import type { ApiCatalogItem, ApiCatalogPluginOptions, } from "../lib/plugins/api-catalog/index.js"; -import { ZuploEnv } from "../zuplo/env.js"; const viteApiPlugin = async ( getConfig: () => ZudokuPluginOptions, @@ -18,13 +17,15 @@ const viteApiPlugin = async ( const virtualModuleId = "virtual:zudoku-api-plugins"; const resolvedVirtualModuleId = "\0" + virtualModuleId; + const initialConfig = getConfig(); + // TODO: For now this is Zuplo specific, but we should make it more generic in the future. // Following options might be possible: // a) Have a processors only file // b) Have a build related config (e.g. Vite, Rehype, Remark, etc.) - const zuploProcessors = ZuploEnv.isZuplo + const zuploProcessors = initialConfig.isZuplo ? await tsImport("../zuplo/with-zuplo-processors.ts", import.meta.url) - .then((m) => m.default(getConfig().rootDir)) + .then((m) => m.default(initialConfig.rootDir)) .catch((e) => { // eslint-disable-next-line no-console console.warn("Failed to load Zuplo processors", e);