-
-
Notifications
You must be signed in to change notification settings - Fork 652
Closed
webpack/webpack
#17339Labels
Description
Is your feature request related to a problem? Please describe.
To conditionally add plugins, && syntax is useful and this works in vite as well:
export default {plugins: [condition && SomePlugin()]}It errors because the schema is too strict:
[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.plugins[4] should be one of these:
object { apply, … } | function
-> Plugin of type object or instanceof Function.
Details:
* configuration.plugins[4] should be an object:
object { apply, … }
-> Plugin instance.
* configuration.plugins[4] should be an instance of function.
-> Function acting as plugin.
Describe the solution you'd like
Accept undefined and null values in plugins array, and just ignore them.
Describe alternatives you've considered
This works, but is clumsy:
export default {plugins: [condition && SomePlugin()].filter(Boolean)}