-
Notifications
You must be signed in to change notification settings - Fork 214
pass clean options to webpack plugin #511
pass clean options to webpack plugin #511
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just a few changes and I think we can roll forward with this. Thanks!
@@ -53,6 +56,11 @@ module.exports = (neutrino, opts = {}) => { | |||
}, options.babel) | |||
}); | |||
|
|||
Object.assign(options.clean, opts.clean || {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need these lines since you are already setting defaults on line 34. You should be able to safely delete L59-63.
@@ -30,7 +30,10 @@ module.exports = (neutrino, opts = {}) => { | |||
polyfills: { | |||
async: true | |||
}, | |||
babel: {} | |||
babel: {}, | |||
clean: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be nice to disable cleaning by passing false
to options.clean
. You should be able to achieve this by changing this to:
clean: opts.clean !== false && {
paths: [neutrino.options.output]
}
Allow passing false to disable the clean plugin
@@ -143,7 +146,12 @@ module.exports = (neutrino, opts = {}) => { | |||
.use(optimize.ModuleConcatenationPlugin); | |||
}) | |||
.when(neutrino.options.command === 'build', (config) => { | |||
neutrino.use(clean, { paths: [neutrino.options.output] }); | |||
if (options.clean) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the rest of the middleware, could you switch this to .when
? Also, I don't think we need to include the output
condition here since you have that set above in the options with paths: [neutrino.options.clean]
:
config.when(options.clean, () => neutrino.use(clean, options.clean));
I'm still a bit confuse with that API but learning... Thanks for the guidance
I discovered that the clean middleware was also not passing all options, so I corrected it on the fly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all your hard work on this! Looks great. 👍
I hope this is the right way to fix #502 :)