webpack-configurator
webpack-configurator copied to clipboard
Alternative plugin syntax
Allow an alternative plugin syntax.
Difference from original:
- Plugin name shouldn't be required.
- Passing arguments in an array is awkward. Better to just treat all arguments after the plugin constructor as arguments to the plugin.
-
removePlugin
can take a constructor which removes all plugins with the same constructor.
config.plugin(webpack.DefinePlugin, {foo: 'foo'}, secondArg, ...)
config.removePlugin(webpack.DefinePlugin)
It should be possible to carry out the first point. There certainly are times when this value serves no purpose.
I did consider the second point at the time of making the plugin method. The problem now is, it wouldn't be possible to have all 3 styles (this, array, and function). Assuming all arguments after the constructor are parameters would make it very difficult to figure out whether the argument is a value or a style.
For instance, the following could mean the plugin is passed one parameter, the entire array, or three parameters, using the array composition style:
config.plugin("my-plugin", MyPlugin, [1, 2, 3])
It also has another issue. How would we go about skipping parameters? For instance, we might only want to modify the second parameter. We could do this with the function style, but I don't see a way to do this in the others. You could pass null
, but what if that's a value that's valid for the particular plugin?
Lastly, given the first point is done, this seems like a reasonable change to make. It would certainly make the method more useful.
Agree. First and last points will be good additions.