Skip to content

Commit

Permalink
feat: let plugins array contain falsy values (#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson authored Mar 24, 2021
1 parent 31d10cb commit be76a30
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,7 +92,7 @@ export interface UserConfig {
/**
* Array of vite plugins to use.
*/
plugins?: (Plugin | Plugin[])[]
plugins?: (PluginOption | PluginOption[])[]
/**
* Configure resolver
*/
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit be76a30

Please sign in to comment.