2.0.0 • Published 8 months ago
esbuild-clean-plugin v2.0.0
esbuild-clean-plugin
An esbuild plugin to clean your build folder.
Installation
npm install esbuild-clean-pluginRequirements
- Node 22.11.0 (LTS) or later.
- esbuild 0.18.20 or later.
Usage
import * as esbuild from 'esbuild';
import { cleanPlugin } from 'esbuild-clean-plugin';
import path from '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(defaultfalse) - Run the plugin in dry mode, not deleting anything. Most useful together with theverboseoption 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(defaultfalse) - Print all files that have been deleted after each run.