1.0.1 • Published 1 year ago

esbuild-plugin-clean v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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 {
  /**
   * file clean patterns (passed to `del`)
   *
   * @default: []
   */
  patterns?: string | string[];

  /**
   * file clean patterns(in onStart only) (passed to `del`)
   *
   * @default: []
   */
  cleanOnStartPatterns?: string | string[];

  /**
   * file clean patterns(in onEnd only) (passed to `del`)
   *
   * @default: []
   */
  cleanOnEndPatterns?: string | string[];

  /**
   * use dry-run mode to see what's going to happen
   *
   * this option will enable verbose option automatically
   *
   * @default: false
   */
  dryRun?: boolean;

  /**
   * extra options passed to `del`
   *
   * @default {}
   */
  options?: DelOptions;

  /**
   * execute clean sync or async (use `del` or `del.sync` for cleaning up)
   *
   * @default: true
   */
  sync?: boolean;

  /**
   * do cleaning in start / end / both
   * maybe in some strange cases you will need it ? :P
   *
   * @default: "start"
   */
  cleanOn?: 'start' | 'end' | 'both';

  /**
   * enable verbose logging to see what's happening
   *
   * @default false
   */
  verbose?: boolean;
}
1.0.1

1 year ago

1.0.0

1 year ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.1.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1-1

3 years ago

0.1.1-0

3 years ago

0.0.2-1

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago