{"id":13606606,"url":"https://github.com/a3mitskevich/vite-font-extractor-plugin","last_synced_at":"2026-04-02T12:00:11.250Z","repository":{"id":188209179,"uuid":"677402044","full_name":"a3mitskevich/vite-font-extractor-plugin","owner":"a3mitskevich","description":"Vite plugin for extracting glyphes by ligatures from font and creating new minimized fonts with them","archived":false,"fork":false,"pushed_at":"2026-03-24T11:17:31.000Z","size":1255,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-25T10:53:46.204Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a3mitskevich.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-08-11T13:36:49.000Z","updated_at":"2026-03-24T10:16:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"4751ce8e-0cc4-40a9-981c-7f98a34ad296","html_url":"https://github.com/a3mitskevich/vite-font-extractor-plugin","commit_stats":null,"previous_names":["a3mitskevich/vite-font-extractor-plugin"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/a3mitskevich/vite-font-extractor-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a3mitskevich%2Fvite-font-extractor-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a3mitskevich%2Fvite-font-extractor-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a3mitskevich%2Fvite-font-extractor-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a3mitskevich%2Fvite-font-extractor-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a3mitskevich","download_url":"https://codeload.github.com/a3mitskevich/vite-font-extractor-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a3mitskevich%2Fvite-font-extractor-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31305971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T09:48:21.550Z","status":"ssl_error","status_checked_at":"2026-04-02T09:48:19.196Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T19:01:10.631Z","updated_at":"2026-04-02T12:00:11.244Z","avatar_url":"https://github.com/a3mitskevich.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Framework-agnostic Plugins"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/logo.png\" alt=\"vite-font-extractor-plugin\" width=\"500\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/vite-font-extractor-plugin?color=blue\u0026label=npm\" alt=\"npm version\" /\u003e\n  \u003cimg src=\"https://img.shields.io/npm/l/vite-font-extractor-plugin\" alt=\"license\" /\u003e\n  \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/a3mitskevich/vite-font-extractor-plugin/node.js.yml?branch=master\u0026label=tests\" alt=\"CI\" /\u003e\n  \u003cimg src=\"https://img.shields.io/npm/dm/vite-font-extractor-plugin\" alt=\"downloads\" /\u003e\n\u003c/p\u003e\n\n# vite-font-extractor-plugin\n\nVite plugin that **extracts only the glyphs you use** from font files — icon fonts, text fonts, or both. Supports Vite\n5, 6, 7, and 8.\n\n```\nBefore:  Material Icons   348 KB (all 2,000+ icons)\nAfter:   Material Icons    12 KB (only 3 icons you need)   → 97% smaller\n```\n\n## Features\n\n- **Icon font minification** — keep only the ligatures you use (Material Icons, FontAwesome, etc.)\n- **Text font subsetting** — keep only specific characters via `?subset=` query\n- **Zero-config auto mode** — detects glyphs from CSS `content: \"...\"` automatically\n- **Google Fonts optimization** — appends `\u0026text=` parameter for server-side subsetting\n- **Works in build and dev** — minifies fonts on-the-fly during development\n- **Vite 5–8 support** — compatible with both Rollup and Rolldown bundlers\n- **Content-based hashing** — output filenames change when config changes (cache-safe)\n- **[Live playground](https://a3mitskevich.github.io/vite-font-extractor-plugin/)** — see the plugin in action\n- **Disk cache** — skip re-minification on repeated builds\n\n## Quick Start\n\n```bash\nnpm install vite-font-extractor-plugin\n```\n\n### Zero-config (auto mode)\n\n```js\n// vite.config.js\nimport FontExtractor from 'vite-font-extractor-plugin'\n\nexport default defineConfig({\n    plugins: [FontExtractor()],\n})\n```\n\nThe plugin scans all CSS for `content: \"...\"` declarations, collects referenced glyphs, and strips everything else from\nfont files.\n\n### Manual mode\n\nSpecify exactly which icons to keep:\n\n```js\nFontExtractor({\n    type: 'manual',\n    targets: [\n        {\n            fontName: 'Material Icons',\n            ligatures: ['close', 'menu', 'search', 'home'],\n        },\n    ],\n})\n```\n\n## Text Font Subsetting\n\nStrip unused characters from text fonts like Roboto, Inter, or Open Sans.\n\n### Via CSS `?subset=` query\n\n```css\n/* Keep only Latin letters and digits */\n@font-face {\n    font-family: 'Roboto';\n    src: url('./fonts/Roboto.woff2?subset=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') format('woff2');\n}\n\n/* Keep a Unicode range (e.g. Cyrillic) */\n@font-face {\n    font-family: 'Roboto';\n    src: url('./fonts/Roboto.woff2?subset=U+0400-04FF') format('woff2');\n}\n\n/* Combine characters and Unicode ranges */\n@font-face {\n    font-family: 'Roboto';\n    src: url('./fonts/Roboto.woff2?subset=ABC,U+0400-04FF') format('woff2');\n}\n```\n\n### Via JS import\n\nUseful for runtime font loading (Rive, Canvas, PDF generators):\n\n```js\nimport fontUrl from './fonts/Roboto.woff2?subset=ABCabc'\n\n// fontUrl is a clean URL to the subsetted font asset\nrive.load({fonts: [fontUrl]})\n```\n\n### Via plugin config\n\n```js\nFontExtractor({\n    type: 'manual',\n    targets: [\n        {\n            fontName: 'Roboto',\n            characters: 'ABCabc0123456789',\n            engine: 'subset',\n        },\n    ],\n})\n```\n\n## Google Fonts\n\nThe plugin appends `\u0026text=` to Google Font URLs, letting Google's servers do the subsetting:\n\n```html\n\n\u003clink href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\"\u003e\n```\n\n```css\n@import \"https://fonts.googleapis.com/icon?family=Material+Icons\";\n```\n\nMulti-family URLs are supported: `family=Material+Icons|Roboto`.\n\n## Caching\n\nEnable disk cache to skip re-minification when fonts and config haven't changed:\n\n```js\nFontExtractor({\n    type: 'manual',\n    targets: [{fontName: 'Material Icons', ligatures: ['close']}],\n    cache: true,              // caches in node_modules/.font-extractor-cache\n    // cache: './my-cache',   // or a custom path\n})\n```\n\nThe cache is automatically cleaned when `cache` is set to `false`.\n\n## Vite Compatibility\n\n| Vite | Status       |\n|------|--------------|\n| v5   | Stable       |\n| v6   | Stable       |\n| v7   | Stable       |\n| v8   | Experimental |\n\n\u003e Vite 8 uses Rolldown instead of Rollup. Icon font minification works fully. The `?subset=` feature has known\n\u003e limitations — see [ROADMAP](./ROADMAP.md) for details.\n\n## API Reference\n\n```typescript\nimport FontExtractor from 'vite-font-extractor-plugin'\n\nFontExtractor(options?: PluginOption): Plugin\n```\n\n### PluginOption\n\n| Option     | Type                                      | Default     | Description                               |\n|------------|-------------------------------------------|-------------|-------------------------------------------|\n| `type`     | `'auto' \\| 'manual'`                      | `'auto'`    | Glyph detection strategy                  |\n| `targets`  | `Target \\| Target[]`                      | —           | Fonts to process. Required in manual mode |\n| `cache`    | `boolean \\| string`                       | —           | Enable disk cache (or custom path)        |\n| `logLevel` | `'info' \\| 'warn' \\| 'error' \\| 'silent'` | Vite config | Log verbosity                             |\n| `apply`    | `'build' \\| 'serve'`                      | both        | Restrict to build or dev mode             |\n| `ignore`   | `string[]`                                | —           | Font names to skip entirely               |\n\n### Target\n\n| Option           | Type                 | Description                                      |\n|------------------|----------------------|--------------------------------------------------|\n| `fontName`       | `string`             | Must match `font-family` in CSS (without quotes) |\n| `ligatures`      | `string[]`           | Icon names to keep (e.g. `['close', 'menu']`)    |\n| `raws`           | `string[]`           | Raw Unicode characters to keep                   |\n| `characters`     | `string`             | Characters string for text font subsetting       |\n| `unicodeRanges`  | `string[]`           | Unicode ranges (e.g. `['U+0400-04FF']`)          |\n| `engine`         | `'icon' \\| 'subset'` | `icon` for icon fonts, `subset` for text fonts   |\n| `withWhitespace` | `boolean`            | Include whitespace glyphs (default: `false`)     |\n\n## Troubleshooting\n\n**Font not being minified?**\n\n- Check that `fontName` exactly matches the `font-family` value in your CSS `@font-face` (without quotes)\n- Make sure the font isn't in the `ignore` list\n\n**Warning: \"has no minify options\"?**\n\n- The plugin found a `@font-face` but the font isn't in `targets`\n- Fonts with `?subset=` URLs don't trigger this warning — they're processed automatically\n- To silence: add the font to `targets`, use `?subset=`, or add to `ignore`\n\n**Google Font URL not transformed?**\n\n- Use spaces in `fontName`: `'Material Icons'`, not `'Material+Icons'`\n\n**Auto mode missing glyphs?**\n\n- Auto mode only detects glyphs from CSS `content: \"...\"` properties\n- If icons are referenced by class name or JS, use `manual` mode instead\n\n## License\n\n[MIT](./LICENSE)\n\n## Contributing\n\nIssues and pull requests are welcome on [GitHub](https://github.com/a3mitskevich/vite-font-extractor-plugin).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa3mitskevich%2Fvite-font-extractor-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa3mitskevich%2Fvite-font-extractor-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa3mitskevich%2Fvite-font-extractor-plugin/lists"}