esbuild-plugin-clean
ESBuild plugin for cleaning up output/assets before building.
Usage
npm install esbuild-plugin-clean --save-dev
pnpm install esbuild-plugin-clean --save-dev
yarn add esbuild-plugin-clean --save-dev
import { build } from 'esbuild';
import { clean } from 'esbuild-plugin-clean';
(async () => {
const res = await build({
entryPoints: ['./demo.ts'],
bundle: true,
outfile: './dist/main.js',
plugins: [
clean({
patterns: ['./dist/*', './dist/assets/*.map.js'],
cleanOnStartPatterns: ['./prepare'],
cleanOnEndPatterns: ['./post'],
}),
],
});
})();
Configurations
This plugin use del under the hood, so you can easily pass del options
to this plugin.
export interface CleanOptions {
patterns?: string | string[];
cleanOnStartPatterns?: string | string[];
cleanOnEndPatterns?: string | string[];
dryRun?: boolean;
options?: DelOptions;
sync?: boolean;
cleanOn?: 'start' | 'end' | 'both';
verbose?: boolean;
}