A Rollup plugin that subsets webfonts at build time based on the characters used in static source files (HTML, CSS, JavaScript/TypeScript) in the bundle. Current stable version: 0.2.0. Release cadence: low, experimental. Key differentiators: automatically extracts character set from bundled assets, uses subset-font under the hood, ships TypeScript types, supports only .woff2 format. Compared to alternatives like 'font-spider' or manual subsetting, it integrates directly into the Rollup build pipeline and requires no runtime overhead. Limitations: does not handle dynamic content or obfuscated code; character set extraction may be incomplete.
npm install rollup-plugin-font-subsetterVerified import paths — ran on the pinned version, not inferred.
Minimal Rollup configuration using the fontSubsetter plugin with TypeScript.
Ensure all possible characters are present in source files or manually specify a character set using plugin options.
Convert fonts to .woff2 format before using this plugin, or use other tools for non-woff2 fonts.
Ensure source code is not obfuscated before build, or manually specify additional characters.
Check for newer versions or alternative plugins if issues arise.
Use import syntax or set 'type': 'module' in package.json.
Use named import: import { fontSubsetter } from 'rollup-plugin-font-subsetter'Ensure that you have .woff2 font files referenced in your source code (e.g., via CSS @font-face) and that the plugin runs after CSS processing.