Reporter to clean files inside dist folder for Parcel V2 (buildSuccess event)
Using npm:
npm install -D parcel-reporter-clean-dist
Using yarn:
yarn add -D parcel-reporter-clean-dist
Using bower:
bower install -D parcel-reporter-clean-dist
First of all, add a new reporter in the Parcel config.
.parcelrc
{
"extends": ["@parcel/config-default"],
"reporters": ["...", "parcel-reporter-clean-dist"] // "..." is needed to include all other pipelines
}
That's it! all files except those generated on the current build will be removed from the dist folder.
If you need to apply specific rules for the cleanup process, then define a config in the package.json of the project.
package.json
// example to remove only some specific file
{
...
"cleanDistFiles": ["dist/file1.txt"]
}
// example to remove only files with specific ext
{
...
"cleanDistFiles": ["dist/**/*.js"]
}
// example to exclude from removal some specific file/folder
{
...
"cleanDistFiles": ["!dist/file1.txt", "!dist/embed"]
}
Type: String[]
Default: ${dist folder of the current build}/**/*
Glob or relative path from where we clean files (root path is the current working directory of the process)
Any contribution is highly appreciated.
The code in this project is licensed under MIT license.