From 8261d35ee1b4a197d6bb4c852b0552d3cef7475c Mon Sep 17 00:00:00 2001 From: ubermanu Date: Wed, 19 Jul 2023 19:14:59 +0200 Subject: [PATCH] fix: plugins not loading properly --- src/actions/build.ts | 1 - src/config.ts | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/actions/build.ts b/src/actions/build.ts index 0b995ab2..e35dc95e 100644 --- a/src/actions/build.ts +++ b/src/actions/build.ts @@ -29,7 +29,6 @@ export const build = async (themeName: string, locale = 'en_US') => { const dest = path.join(themeConfig.dest, locale) for (const plugin of themeConfig.plugins) { try { - // @ts-ignore await plugin({ ...themeConfig, dest, diff --git a/src/config.ts b/src/config.ts index edb5c0d9..bfd4e7ac 100644 --- a/src/config.ts +++ b/src/config.ts @@ -92,17 +92,23 @@ export const getThemeConfig = memo(async (themeName: string) => { } } - const pluginList: Plugin[] | string[] = [] + const pluginList: Array = [] // Add the preset plugins to the plugin list if (userConfig.presets) { const presets = await Promise.all(userConfig.presets.map(transformPresetDefinition)) presets.forEach((preset) => { - // @ts-ignore - pluginList.push(...preset.plugins) + if (Array.isArray(preset.plugins)) { + preset.plugins.forEach((plugin) => pluginList.push(plugin)) + } }) } + // Add the user plugins to the plugin list + if (userConfig.plugins) { + userConfig.plugins.forEach((plugin) => pluginList.push(plugin)) + } + // Add support for multiple plugin formats // It can be 'string', 'object' or 'function' const plugins = await Promise.all(pluginList.map(transformPluginDefinition))