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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/neutrino-middleware-clean/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
const CleanPlugin = require('clean-webpack-plugin');
const merge = require('deepmerge');

module.exports = (neutrino, options = {}) => {
const { paths, root } = merge({ paths: [], root: neutrino.options.root }, options);
module.exports = (neutrino, opts = {}) => {
const options = merge({
paths: [],
root: neutrino.options.root,
verbose: neutrino.options.debug
}, opts);

const { paths } = options;
delete options.paths;

neutrino.config
.plugin(options.pluginId || 'clean')
.use(CleanPlugin, [paths, { root, verbose: neutrino.options.debug }]);
.plugin(opts.pluginId || 'clean')
.use(CleanPlugin, [paths, options]);
};
7 changes: 5 additions & 2 deletions packages/neutrino-preset-web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ module.exports = (neutrino, opts = {}) => {
polyfills: {
async: true
},
babel: {}
babel: {},
clean: opts.clean !== false && {
paths: [neutrino.options.output]
}
}, opts);

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