Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

pass clean options to webpack plugin #511

Merged
merged 6 commits into from Dec 4, 2017

Conversation

zeropaper
Copy link
Contributor

I hope this is the right way to fix #502 :)

Copy link
Member

@eliperelman eliperelman left a 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 || {});
Copy link
Member

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: {
Copy link
Member

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) {
Copy link
Member

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));

@zeropaper
Copy link
Contributor Author

I discovered that the clean middleware was also not passing all options, so I corrected it on the fly.

Copy link
Member

@eliperelman eliperelman left a 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. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants