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..60e8065 100644 --- a/index.js +++ b/index.js @@ -133,7 +133,15 @@ 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; + return; + } + }); + if (!include) { excludedChildren.push(childFile); }