esbuild-clean-plugin is a utility designed to integrate with esbuild's build process to automatically clean the designated output directory. It's currently stable at version 2.0.0, indicating a mature and maintained state. While a specific release cadence isn't explicitly stated, plugins often follow a release cycle aligned with their host bundler or address specific feature/bug updates as needed. Its primary differentiator lies in its deep integration as an esbuild plugin, leveraging esbuild's internal context to precisely identify and clean generated files. It offers crucial options like `initialCleanPatterns` to clear the directory before a new build, `dry` run mode for testing, and `verbose` output to track deleted files, providing fine-grained control over the build folder lifecycle directly within the esbuild configuration. This makes it a robust solution for ensuring a clean build environment without external scripts.
npm install esbuild-clean-pluginVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up `esbuild-clean-plugin` within an esbuild context, showcasing how to configure it for initial directory cleaning and verbose output.
Upgrade your Node.js environment to version 22.11.0 or newer. Consider using `nvm` or similar version managers.
Ensure your project's `esbuild` dependency is updated to version `^0.18.20` or newer. Run `npm install esbuild@latest`.
Always include `metafile: true` and `outdir: 'your/output/directory'` in your `esbuild.build` or `esbuild.context` configuration when using this plugin.
Use ES Module `import` syntax: `import { cleanPlugin } from 'esbuild-clean-plugin';`Add `metafile: true` to your `esbuild` configuration object.
Add `outdir: 'your/build/directory'` to your `esbuild` configuration object.