# rollup-plugin-delete

> Delete files and folders using Rollup

Latest version **3.0.2** (published 2025-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-delete
pnpm add rollup-plugin-delete
yarn add rollup-plugin-delete
bun add rollup-plugin-delete
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2025-12-11 |
| First published | 2018-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 1 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 70 |
| Author | Vlad Shcherbin |
| Maintainers | shcherbin |
| Keywords | rollup, rollup-plugin, delete, clear, clean, remove, file, folder, directory |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-delete
- Repository: https://github.com/vladshcherbin/rollup-plugin-delete
- Homepage: https://github.com/vladshcherbin/rollup-plugin-delete#readme
- Issues: https://github.com/vladshcherbin/rollup-plugin-delete/issues
- npm.io page: https://npm.io/package/rollup-plugin-delete

## Dependencies (1)

- [del](https://npm.io/package/del.md) ^8.0.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 3.0.2 (latest) — 2025-12-11
- 3.0.1 — 2025-03-06
- 3.0.0 — 2025-02-19
- 2.2.0 — 2025-02-18
- 2.1.0 — 2024-09-08
- 2.0.0 — 2020-06-10
- 1.2.0 — 2020-01-26
- 1.1.0 — 2019-08-21
- 1.0.0 — 2019-05-05
- 0.2.2 — 2019-04-03
- 0.2.1 — 2019-01-29
- 0.2.0 — 2019-01-23
- 0.1.2 — 2018-07-03
- 0.1.1 — 2018-07-03
- 0.1.0 — 2018-07-03

## README

# rollup-plugin-delete

Delete files and folders using Rollup.

## About

This plugin is useful when you want to clean `dist` or other folders and files before bundling. It's using [del package](https://github.com/sindresorhus/del) inside, check it for [pattern examples](https://github.com/sindresorhus/del?tab=readme-ov-file#patterns) and [additional options](https://github.com/sindresorhus/del?tab=readme-ov-file#options).

## Installation

```bash
# pnpm
pnpm add rollup-plugin-delete -D

# yarn
yarn add rollup-plugin-delete -D

# npm
npm install rollup-plugin-delete -D
```

## Usage

```js
// rollup.config.js
import del from 'rollup-plugin-delete'

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/app.js'
  },
  plugins: [
    del({ targets: 'dist' })
  ]
}
```

### Configuration

There are some useful options:

#### targets

A string or an array of patterns of files and folders to be deleted. Default is `[]`.

```js
// Folder
del({
  targets: 'build'
})

// Files
del({
  targets: 'dist/*.js'
})

// Multiple targets
del({
  targets: ['dist/*', 'images/*.webp']
})
```

#### verbose

Output removed files and folders to console. Default is `false`.

> [!NOTE]  
> Use \* (wildcard character) in pattern to show removed files

```js
del({
  targets: 'dist/*',
  verbose: true
})
```

#### hook

[Rollup hook](https://rollupjs.org/plugin-development/#build-hooks) the plugin should use. Default is `buildStart`.

```js
del({
  targets: 'dist/*',
  hook: 'buildEnd'
})
```

#### runOnce

Type: `boolean` | Default: `false`

Delete items once. Useful in watch mode.

```js
del({
  targets: 'dist/*',
  runOnce: true
})
```

All other options are passed to [del package](https://github.com/sindresorhus/del) which is used inside.

## License

MIT

---
_Source: https://npm.io/package/rollup-plugin-delete · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
