Rollup plugin for PurgeIcons, a tool that removes unused icon imports from icon libraries (e.g., Material Design, Font Awesome) to reduce bundle size. Version 0.10.0 is current stable; maintained by Anthony Fu. It works by analyzing your source code for used icon names and tree-shaking the rest. Key differentiators: automatic detection of icon usage, supports multiple icon sets, and integrates as a rollup plugin with zero configuration options needed in many cases. Requires @purge-icons/core and @purge-icons/generated as peer dependencies.
npm install rollup-plugin-purge-iconsVerified import paths — ran on the pinned version, not inferred.
Minimal rollup config using PurgeIcons plugin with default options.
Ensure the import is present in your entry file and not tree-shaken away.
Use import syntax. If you need CommonJS, consider using dynamic import() or transpile.
Upgrade to Node >=14 for future compatibility.
Install them as devDependencies: npm i @purge-icons/core @purge-icons/generated -D
Use import syntax or set type: 'module' in package.json.
Run npm install @purge-icons/generated --save-dev
Switch to export default or named exports syntax.