cleandir-webpack-plugin
This plugin allows you to delete files/directories before or after bundle compilation.
Comparing to most popular cleanup plugin, cleandir-webpack-plugin
provides you ability to run plugin after files was written to output directory and ability to exclude files with glob patterns.
Installation
npm i --save cleandir-webpack-plugin
Example
const CleanDirWebpackPlugin = require("cleandir-webpack-plugin");
module.exports = {
plugins: [
new CleanDirWebpackPlugin("dist/"),
new CleanDirWebpackPlugin([
"dist/css/*.js",
"dist/some/directory/**",
],
{
stage: "after",
exclude: "dist/some/directory/**.log",
silent: true,
},
),
],
};
Usage
const CleanDirWebpackPlugin = require("cleandir-webpack-plugin");
module.exports = {
plugins:[
new CleanDirWebpackPlugin(paths [, options])
]
}
paths (required)
Paths can be a valuable string or an array of strings.
Each string should be a valid glob pattern (node-glob is used under the hood).
options (optional)
const options = {
stage: "before",
exclude: [],
verbose: true,
silent: false,
dryRun: false,
allowExternal: false,
root: path.dirname(module.parent.filename),
}
Tests
npm i
npm run test
Coverage
npm i
npm run test:coverage