From cd367c156bb1dc7ddbcd9842c6b3def34e41ca8b Mon Sep 17 00:00:00 2001 From: Frank Bonetti Date: Wed, 25 Jan 2017 12:32:34 -0600 Subject: [PATCH 1/2] Allow using regex in exclude --- README.md | 2 +- index.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4832134..6cf2a58 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ module.exports = { root: '/full/project/path', verbose: true, dry: false, - exclude: ['shared.js'] + exclude: ['shared.js', /style_.+\.css/] }) ] } diff --git a/index.js b/index.js index b306d2d..86c6ec0 100644 --- a/index.js +++ b/index.js @@ -133,7 +133,14 @@ CleanWebpackPlugin.prototype.apply = function () { if (pathStat.isDirectory()) { childrenAfterExcluding = fs.readdirSync(rimrafPath) .filter(function (childFile) { - var include = _this.options.exclude.indexOf(childFile) < 0; + var include = true; + + _this.options.exclude.forEach(function(exclusionRule) { + if (childFile.match(exclusionRule)) { + include = false; + } + }); + if (!include) { excludedChildren.push(childFile); } From bd2343253728479d9eb7412dff02b6b9fd82b118 Mon Sep 17 00:00:00 2001 From: Frank Bonetti Date: Wed, 25 Jan 2017 12:33:49 -0600 Subject: [PATCH 2/2] exit loop if excluded match found --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 86c6ec0..60e8065 100644 --- a/index.js +++ b/index.js @@ -138,6 +138,7 @@ CleanWebpackPlugin.prototype.apply = function () { _this.options.exclude.forEach(function(exclusionRule) { if (childFile.match(exclusionRule)) { include = false; + return; } });