{"id":21982,"library":"rollup-plugin-del","title":"rollup-plugin-del","description":"A Rollup plugin that deletes specified files or directories before or after a build, commonly used to clean the output directory (e.g., dist). Version 1.0.1, last updated 2022. It wraps the `del` package to support glob patterns and automatically falls back to Rollup's output dir/file. Lightweight, no external plugin dependencies. Differentiates from @rollup/plugin-clean by offering glob flexibility and automatic output detection.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/a572251465/rollup-plugin-del","tags":["javascript","rollup","plugin","del","dist"],"install":[{"cmd":"npm install rollup-plugin-del","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-del","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-del","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core deletion logic uses the del package for glob matching","package":"del","optional":false}],"imports":[{"note":"Plugin is exported as default. Named export does not exist.","wrong":"import { del } from 'rollup-plugin-del'","symbol":"default","correct":"import del from 'rollup-plugin-del'"},{"note":"In CommonJS, the default export is accessed via .default because the package uses ESM.","wrong":"const del = require('rollup-plugin-del')","symbol":"default","correct":"const del = require('rollup-plugin-del').default"},{"note":"TypeScript with `esModuleInterop: false` may require `import del = require('rollup-plugin-del')` but that syntax is uncommon; prefer `esModuleInterop: true`.","wrong":"import del = require('rollup-plugin-del')","symbol":"default","correct":"import del from 'rollup-plugin-del'"}],"quickstart":{"code":"// rollup.config.js\nimport del from 'rollup-plugin-del';\nimport resolve from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    del(), // deletes dist before build\n    resolve(),\n    commonjs()\n  ]\n};","lang":"javascript","description":"Basic Rollup config that cleans the dist directory using default output detection before bundling."},"warnings":[{"fix":"Specify a subdirectory like 'dist', not the root.","message":"Uses `del` under the hood which cannot delete the current working directory itself – avoid using dest: process.cwd()","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Restart Rollup after changes or consider other cleanup strategies.","message":"Plugin runs once on build start – not on watch rebuild. Files deleted during watch may cause errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run `npm install del -D` alongside rollup-plugin-del.","message":"The `del` peer dependency is not bundled; you must install `del` separately if not already present.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install del: npm install del --save-dev","cause":"Missing peer dependency `del`.","error":"Error: Cannot find module 'del'"},{"fix":"Change to `import del from 'rollup-plugin-del'`","cause":"Using named import { del } instead of default import.","error":"TypeError: del is not a function"},{"fix":"Run with appropriate permissions or adjust file paths.","cause":"Attempting to delete files that the process does not have permissions for.","error":"Error: EACCES: permission denied, unlink '...'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}