Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: let plugins array contain falsy values #1649

Merged
merged 1 commit into from
Mar 24, 2021

Conversation

aleclarson
Copy link
Member

No description provided.

@Shinigami92
Copy link
Member

@aleclarson Could you provide a description why this is useful?

@@ -67,7 +69,7 @@ export interface UserConfig {
/**
* Array of vite plugins to use.
*/
plugins?: (Plugin | Plugin[])[]
plugins?: (PluginOption | PluginOption[])[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: In which situation is an array with possible falsy values helpful?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matias-capeletto Is it wanted behavior that plugins can hold an array of array of plugins? Looks weird, but I currently don't know better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is used to create presets, a plugin can return several plugins. You can check out the vue plugin for an example

@@ -43,6 +43,8 @@ export function defineConfig(config: UserConfigExport): UserConfigExport {
return config
}

export type PluginOption = Plugin | false | null | undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (if-minor): The PluginOption itself should not be undefined
The plugin property is already marked as optional

@Shinigami92 Shinigami92 added the p2-nice-to-have Not breaking anything but nice to have (priority) label Mar 23, 2021
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, rollup also ignore falsy plugins: https://rollupjs.org/guide/en/#plugins

Falsy plugins will be ignored, which can be used to easily activate or deactivate plugins.

@patak-dev patak-dev merged commit be76a30 into vitejs:main Mar 24, 2021
@aleclarson aleclarson deleted the feat/falsy-plugins branch June 24, 2021 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants