diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 68787fa3369a66..9bbf4c10624335 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -242,14 +242,14 @@ export async function resolveConfig( // run config hooks const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins] - userPlugins.forEach((p) => { + for (const p of userPlugins) { if (p.config) { - const res = p.config(config, configEnv) + const res = await p.config(config, configEnv) if (res) { config = mergeConfig(config, res) } } - }) + } // resolve root const resolvedRoot = normalizePath( diff --git a/packages/vite/src/node/plugin.ts b/packages/vite/src/node/plugin.ts index 7bef2402de4729..4f13439604f86e 100644 --- a/packages/vite/src/node/plugin.ts +++ b/packages/vite/src/node/plugin.ts @@ -61,7 +61,10 @@ export interface Plugin extends RollupPlugin { * Note: User plugins are resolved before running this hook so injecting other * plugins inside the `config` hook will have no effect. */ - config?: (config: UserConfig, env: ConfigEnv) => UserConfig | null | void + config?: ( + config: UserConfig, + env: ConfigEnv + ) => UserConfig | null | void | Promise /** * Use this hook to read and store the final resolved vite config. */