A plugin (likely compatible with your build tool) allowing you to remove unused glyphs from your output font files to improve page-load and time-to-first-byte.
Uses glyphhanger
under the hood but with the added functionality of overwriting the build output fonts, rather than creating new ones (and having to create links to/stylesheets for them).
glyphhanger
is also required as a peer dependency:
npm i --save-dev @ernxst/subfont glyphhanger
yarn add -D @ernxst/subfont glyphhanger
pnpm i -D @ernxst/subfont glyphhanger
Note that this integration only works for static builds, it does nothing (rather than erroring) when SSR is enabled.
You may get unexpected results when using this plugin with dynamically generated content.
import { defineConfig } from "astro/config";
import subfont from "@ernxst/subfont/astro";
export default defineConfig({
integrations: [subfont()],
})
import { defineConfig } from "vite";
import subfont from "@ernxst/subfont/vite";
export default defineConfig({
plugins: [subfont()],
})
import { defineConfig } from "rollup";
import subfont from "@ernxst/subfont/rollup";
export default defineConfig({
plugins: [subfont()],
})
import esbuild from "esbuild";
import subfont from "@ernxst/subfont/esbuild";
esbuild.build({
plugins: [subfont()],
}).catch(() => process.exit(1));
In CommonJS form:
const SubfontWebpackPlugin = require("@ernxst/subfont/webpack");
module.exports = {
plugins: [new SubfontWebpackPlugin()],
}
log
- Whether to log to stdout.- default:
true
- default:
To get started with development, you will need an editor (VS Code is recommended), a browser that runs JavaScript and some extra prerequisites:
To get started with contributing to this project, first fork this git repository:
git clone https://github.com/Ernxst/subfont.git
Then, install dependencies and start coding.
If you have a suggestion that would make this app better, please fork the repo and create a pull request. You can also
simply open an issue with the tag "enhancement
".
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.