Reporter to clean dist files for Parcel v2
npm install parcel-reporter-clean-dist
Reporter to clean files inside dist folder for Parcel V2 (buildSuccess event)
Using npm:
``shell`
npm install -D parcel-reporter-clean-dist`
Using yarn:shell`
yarn add -D parcel-reporter-clean-dist`
Using bower:shell`
bower install -D parcel-reporter-clean-dist
First of all, add a new reporter in the Parcel config.
.parcelrc
`json`
{
"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
`js
// 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"]
}
`
#### cleanDistFiles
Type: String[]${dist folder of the current build}/*/`
Default:
Glob or relative path from where we clean files (root path is the current working directory of the process)
[node]: https://nodejs.org/
[parcel]: https://parceljs.org/