From cedac7222a2cb9a0436291af0175dd8a66bef694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Mon, 31 Jul 2023 23:31:41 +0200 Subject: [PATCH 1/2] fix: vite mergeConfig doesn't accept callback params This is exactly the same commit as https://github.com/histoire-dev/histoire/commit/dcd5d9f, just for v0.14.x --- packages/histoire/src/node/config.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/histoire/src/node/config.ts b/packages/histoire/src/node/config.ts index 9499b7e5..00d418a7 100644 --- a/packages/histoire/src/node/config.ts +++ b/packages/histoire/src/node/config.ts @@ -174,14 +174,18 @@ export async function loadConfigFile (configFile: string): Promise { if (obj[key] && key === 'vite') { const initialValue = obj[key] - if (typeof value === 'function') { - obj[key] = async (...args) => { - const result = await value(...args) - return mergeViteConfig(initialValue, result) - } - } else { - obj[key] = mergeViteConfig(initialValue, value) + + // Convert to functions + const initialFn: (...args: any[]) => Promise = typeof initialValue === 'function' ? initialValue : async () => initialValue + const valueFn: (...args: any[]) => Promise = typeof value === 'function' ? value : async () => value + + obj[key] = async (...args) => { + // `mergeViteConfig` doesn't accept functions so we need to call them + const initialResult = await initialFn(...args) + const valueResult = await valueFn(...args) + return mergeViteConfig(initialResult, valueResult) } + return true } From f3925129fe7f303716cfe78ac1cbaae76d08ae65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Mon, 31 Jul 2023 23:31:41 +0200 Subject: [PATCH 2/2] fix: vite mergeConfig doesn't accept callback params --- packages/histoire/src/node/config.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/histoire/src/node/config.ts b/packages/histoire/src/node/config.ts index 9499b7e5..00d418a7 100644 --- a/packages/histoire/src/node/config.ts +++ b/packages/histoire/src/node/config.ts @@ -174,14 +174,18 @@ export async function loadConfigFile (configFile: string): Promise { if (obj[key] && key === 'vite') { const initialValue = obj[key] - if (typeof value === 'function') { - obj[key] = async (...args) => { - const result = await value(...args) - return mergeViteConfig(initialValue, result) - } - } else { - obj[key] = mergeViteConfig(initialValue, value) + + // Convert to functions + const initialFn: (...args: any[]) => Promise = typeof initialValue === 'function' ? initialValue : async () => initialValue + const valueFn: (...args: any[]) => Promise = typeof value === 'function' ? value : async () => value + + obj[key] = async (...args) => { + // `mergeViteConfig` doesn't accept functions so we need to call them + const initialResult = await initialFn(...args) + const valueResult = await valueFn(...args) + return mergeViteConfig(initialResult, valueResult) } + return true }