Skip to content

Commit

Permalink
updated readme, cleaned up code as per PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
strootje committed Apr 10, 2021
1 parent a164c19 commit 6d8a232
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

A webpack plugin to remove/clean your build folder(s).

> NOTE: Node v8+ and webpack v3+ are supported and tested.
> NOTE: Node v10+ and webpack v4+ are supported and tested.
## About

Expand Down Expand Up @@ -101,7 +101,11 @@ new CleanWebpackPlugin({
// Use !negative patterns to exclude files
//
// default: ['**/*']
cleanOnceBeforeBuildPatterns: ['**/*', '!static-files*', '!directoryToExclude/**'],
cleanOnceBeforeBuildPatterns: [
'**/*',
'!static-files*',
'!directoryToExclude/**',
],
cleanOnceBeforeBuildPatterns: [], // disables cleanOnceBeforeBuildPatterns

// Removes files after every build (including watch mode) that match this pattern.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"semver": "^6.0.0",
"temp-sandbox": "^3.0.0",
"typescript": "^3.4.5",
"webpack": "^5.11.1"
"webpack": "^5.31.2"
},
"dependencies": {
"del": "^4.1.1"
Expand Down
24 changes: 2 additions & 22 deletions src/clean-webpack-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,28 +238,7 @@ class CleanWebpackPlugin {
/**
* Fetch Webpack's output asset files
*/
const assets =
stats.toJson({
assets: true,
}).assets || [];

const relatedAssets = assets
.map((asset) => {
return (
(asset.related &&
Array.isArray(asset.related) &&
asset.related) ||
[]
);
})
.reduce((previousAssets, currentAssets) => {
return [...previousAssets, ...currentAssets];
}, []);

const allAssets = [...assets, ...relatedAssets];
const assetList = allAssets.map((asset) => {
return asset.name;
});
const assetList = Object.keys(stats.compilation.assets);

/**
* Get all files that were in the previous build but not the current
Expand Down Expand Up @@ -341,6 +320,7 @@ class CleanWebpackPlugin {
throw new Error(message);
}

/* istanbul ignore next */
throw error;
}
}
Expand Down

0 comments on commit 6d8a232

Please sign in to comment.