https://github.com/jwilsson/esbuild-clean-plugin
An esbuild plugin to clean your build folder.
https://github.com/jwilsson/esbuild-clean-plugin
clean esbuild esbuild-plugin
Last synced: 10 months ago
JSON representation
An esbuild plugin to clean your build folder.
- Host: GitHub
- URL: https://github.com/jwilsson/esbuild-clean-plugin
- Owner: jwilsson
- License: mit
- Created: 2021-05-15T12:00:08.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-18T07:29:22.000Z (about 1 year ago)
- Last Synced: 2025-04-18T21:34:19.353Z (about 1 year ago)
- Topics: clean, esbuild, esbuild-plugin
- Language: TypeScript
- Homepage:
- Size: 37.1 KB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# esbuild-clean-plugin
[](https://www.npmjs.com/package/esbuild-clean-plugin)
[](https://github.com/jwilsson/esbuild-clean-plugin/actions/workflows/build.yml)
An [esbuild](https://esbuild.github.io/) plugin to clean your build folder.
## Installation
```sh
npm install esbuild-clean-plugin
```
### Requirements
* Node 22.11.0 (LTS) or later.
* esbuild 0.18.20 or later.
## Usage
```js
import * as esbuild from 'esbuild';
import { cleanPlugin } from 'esbuild-clean-plugin';
import path from 'node:path';
const context = await esbuild.context({
bundle: true,
entryPoints: [path.resolve(import.meta.dirname, 'index.js')],
metafile: true,
outdir: path.resolve(import.meta.dirname, 'dist'),
plugins: [cleanPlugin({
// Plugin options
})],
});
await context.watch();
```
*Note: The `metafile` and `outdir` options must be set for the plugin to have any effect.*
### Options
* `dry` (default `false`) - Run the plugin in dry mode, not deleting anything. Most useful together with the `verbose` option to see what would have been deleted.
* `initialCleanPatterns` (default `['**/*']`) - File patterns to remove on plugin setup, useful to clean the build directory before creating new files. Pass an empty array to disable it.
* `verbose` (default `false`) - Print all files that have been deleted after each run.