{"id":25392,"library":"esbuild-plugin-purgecss","title":"esbuild-plugin-purgecss","description":"An esbuild plugin that integrates PurgeCSS to remove unused CSS from your bundled output. Currently at version 0.0.6 (stable, no recent updates). It allows configuration via PurgeCSS options and content paths. Key differentiator: lightweight, zero-config setup for esbuild users wanting to eliminate dead CSS during bundling. Alternatives like purgecss-webpack-plugin are more complex and Webpack-specific. Supports TypeScript types. Release cadence: low—last update over a year ago.","status":"active","version":"0.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/GitHubJiKe/esbuild-plugin-purgecss","tags":["javascript","esbuild","plugin","purgecss","typescript"],"install":[{"cmd":"npm install esbuild-plugin-purgecss","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-purgecss","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-purgecss","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for CSS removal logic","package":"purgecss","optional":false}],"imports":[{"note":"Default export only; named import will fail.","wrong":"const { purgecssPlugin } = require('esbuild-plugin-purgecss')","symbol":"default","correct":"import purgecssPlugin from 'esbuild-plugin-purgecss'"},{"note":"CJS users: the plugin is the default export, no need for .default.","wrong":"const purgecssPlugin = require('esbuild-plugin-purgecss').default","symbol":"default (CommonJS)","correct":"const purgecssPlugin = require('esbuild-plugin-purgecss')"},{"note":"TypeScript types are included; use default import for type safety.","wrong":"","symbol":"type definitions","correct":"import purgecssPlugin from 'esbuild-plugin-purgecss'"}],"quickstart":{"code":"import purgecssPlugin from 'esbuild-plugin-purgecss';\nimport * as esbuild from 'esbuild';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    purgecssPlugin({\n      content: ['./src/**/*.html'],\n      safelist: ['keep-me'],\n    })\n  ]\n});","lang":"typescript","description":"Basic usage: removes unused CSS by scanning HTML files for class references. Configurable content paths and safelist."},"warnings":[{"fix":"Ensure your esbuild build outputs CSS to a file; plugin will process it automatically.","message":"Plugin only runs on CSS output, not on CSS files imported in JS. You must extract CSS (e.g., with esbuild's CSS loader) before purging.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider switching to a more maintained alternative like purgecss-webpack-plugin if using webpack or check if the repo is active.","message":"Version 0.0.6 is the latest; no updates for over a year. May not support future esbuild versions.","severity":"deprecated","affected_versions":"<=0.0.6"},{"fix":"Disable esbuild's CSS minification or chain plugins carefully.","message":"Incompatible with esbuild's native CSS minification if you rely on content analysis—only first pass is done.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Validate options against PurgeCSS documentation, e.g., use 'content' not 'paths'.","message":"Plugin options are passed directly to PurgeCSS; incorrect option names will silently fail (no error).","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install purgecss: npm install purgecss","cause":"Missing peer dependency purgecss.","error":"Error: Cannot find module 'purgecss'"},{"fix":"Use default import: import purgecssPlugin from 'esbuild-plugin-purgecss'","cause":"Using named import instead of default import.","error":"TypeError: purgecssPlugin is not a function"},{"fix":"Ensure content globs correctly resolve to files that reference CSS classes.","cause":"Content paths don't match any HTML/JS files; no CSS to purge.","error":"No output files were generated"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}