Allow falsy values in plugins array
See original GitHub issueDo you want to request a feature or report a bug? Feature.
What is the current behavior?
passing undefined
, null
, or false
in a plugins array results in the following error:
TypeError: arguments[i].apply is not a function
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
If this is a feature request, what is motivation or use case for changing the behavior? Allowing falsy values in the plugins array would allow much simpler plugin definition:
plugins: [
isProd ? new webpack.optimize.UglifyJsPlugin() : null,
//or
isDev && new someOtherPlugin(),
]
There are other ways to accomplish this right now, but all of them are clunkier, more verbose, and/or more repetitive. Case in point: The noop-webpack-plugin exists to enable this pattern, but it shouldn’t have to exist at all.
I’m happy to submit a PR for it when I get around to it, but won’t be hurt if anyone else would like to beat me to it.
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
I installed webpack 3.5.3 to verify that this is still not supported before filing the issue.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (7 by maintainers)
Just
webpack.config.js
?
Yes, close issue, thanks everyone!