rollup-plugin-cleaner

raw JSON →
1.0.0 verified Mon Apr 27 auth: no javascript

A Rollup plugin that deletes specified directories before each build, ensuring clean output. Version 1.0.0 is the latest stable release; the package is minimal and rarely updated. It simplifies cleaning build artifacts compared to manually using `rimraf` or shell commands, with options for silent mode. Alternative plugins like rollup-plugin-delete offer similar functionality with more features.

error TypeError: cleaner is not a function
cause Importing named export instead of default export
fix
Use import cleaner from 'rollup-plugin-cleaner'.
error Error: Cannot find module 'rollup-plugin-cleaner'
cause Package not installed or not in node_modules
fix
Run npm install rollup-plugin-cleaner --save-dev.
gotcha Ensure targets array contains absolute or relative paths; using '.' may delete unintended files.
fix Specify explicit paths like './build/' instead of '.'.
deprecated Plugin is not actively maintained; may not support latest Rollup versions.
fix Consider using rollup-plugin-delete as a maintained alternative.
npm install rollup-plugin-cleaner
yarn add rollup-plugin-cleaner
pnpm add rollup-plugin-cleaner

Configures rollup-plugin-cleaner to delete the ./build directory before each build.

// rollup.config.js
import cleaner from 'rollup-plugin-cleaner';

export default {
  input: './src/index.js',
  output: {
    dir: './build',
    format: 'cjs',
  },
  plugins: [
    cleaner({
      targets: ['./build/'],
      silent: true,
    }),
  ],
};