{"id":22610,"library":"vite-plugin-clean","title":"vite-plugin-clean","description":"Vite plugin to remove/clean build files or folders before building. Version 2.0.1, maintained with sparse releases. Key differentiator: simple, zero-config clean of 'dist' by default with optional custom target files. Lightweight alternative to 'rimraf' or shell commands, integrates directly into Vite's build lifecycle. No extra dependencies.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/z-ti/vite-plugin-clean","tags":["javascript","vite-plugin","vite","clean","remove","folder","directory","directories","files","typescript"],"install":[{"cmd":"npm install vite-plugin-clean","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-clean","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-clean","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM only; supports default export.","wrong":"const cleanPlugin = require('vite-plugin-clean')","symbol":"default import (cleanPlugin)","correct":"import cleanPlugin from 'vite-plugin-clean'"},{"note":"The module exports a default function only.","wrong":"import { clean } from 'vite-plugin-clean'","symbol":"default import (alias)","correct":"import clean from 'vite-plugin-clean'"},{"note":"Ships TypeScript types; no separate type import needed.","wrong":"","symbol":"TypeScript support","correct":"import cleanPlugin from 'vite-plugin-clean'"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite'\nimport cleanPlugin from 'vite-plugin-clean'\n\nexport default defineConfig({\n  plugins: [\n    cleanPlugin({\n      targetFiles: ['dist', 'temp']\n    })\n  ]\n})","lang":"javascript","description":"Demonstrates plugin usage with custom targetFiles to remove 'dist' and 'temp' directories before build."},"warnings":[{"fix":"Ensure target files are not needed during dev; consider using 'buildStart' only by wrapping in conditional.","message":"Plugin cleans target files before every build, including dev server start.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Double-check file paths; test with non-critical directories first.","message":"targetFiles are deleted synchronously and irreversibly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use targetFiles: ['dist'] instead.","message":"Option 'cleanDist' removed in v2.0.0.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev vite-plugin-clean`","cause":"Missing npm install or mismatched package name.","error":"Error: Cannot find module 'vite-plugin-clean'"},{"fix":"Use `import cleanPlugin from 'vite-plugin-clean'` (default import).","cause":"Incorrect import style (named instead of default).","error":"TypeError: cleanPlugin is not a function"},{"fix":"Use absolute paths or ensure relative paths are correct from project root.","cause":"targetFiles paths are relative to project root but might be incorrect.","error":"Clean plugin not working: nothing is deleted."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}