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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/neutrino-preset-web/index.js
Expand Up @@ -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]
}

paths: [neutrino.options.output]
}
}, opts);

Object.assign(options, {
Expand All @@ -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.

if (!options.clean.paths.includes(neutrino.options.output)) {
options.clean.paths.push(neutrino.options.output);
}

const staticDir = join(neutrino.options.source, 'static');
const presetEnvOptions = options.babel.presets[0][1];

Expand Down Expand Up @@ -143,7 +151,7 @@ module.exports = (neutrino, opts = {}) => {
.use(optimize.ModuleConcatenationPlugin);
})
.when(neutrino.options.command === 'build', (config) => {
neutrino.use(clean, { paths: [neutrino.options.output] });
neutrino.use(clean, options.clean);
neutrino.use(copy, {
patterns: [{
context: staticDir,
Expand Down