diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 6ba9279bdad6f4..6c828b94dde93e 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -58,6 +58,8 @@ export function defineConfig(config: UserConfigExport): UserConfigExport { return config } +export type PluginOption = Plugin | false | null | undefined + export interface UserConfig { /** * Project root directory. Can be an absolute path, or a path relative from @@ -90,7 +92,7 @@ export interface UserConfig { /** * Array of vite plugins to use. */ - plugins?: (Plugin | Plugin[])[] + plugins?: (PluginOption | PluginOption[])[] /** * Configure resolver */ @@ -232,8 +234,8 @@ export async function resolveConfig( // resolve plugins const rawUserPlugins = (config.plugins || []).flat().filter((p) => { - return !p.apply || p.apply === command - }) + return p && (!p.apply || p.apply === command) + }) as Plugin[] const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins( rawUserPlugins )