vite-plugin-fontm
v0.1.3
Published
A Vite plugin for font subsetting and minification using Fontmin
Downloads
11
Maintainers
Readme
vite-plugin-fontm
A Vite plugin for compressing font files using Fontmin.
Installation
npm i vite-plugin-fontm
Usage
Add the plugin to your vite.config.js
:
import { defineConfig } from 'vite'
import fontminPlugin from 'vite-plugin-fontm'
export default defineConfig({
plugins: [
fontminPlugin({
fonts: [
{
fontSrc: ['./src/assets/fonts/*.ttf'],
fontDest: './src/assets/compressed-fonts/',
inputPath: ['./src/**/*.{vue,js,ts}'], // or input: 'Your text here',
// input: 'Your text here',
}
],
runOnceInDev: true // Optional: compress fonts in development mode only once
})
]
})
Configuration
The plugin accepts the following options:
fonts
: An array of font configurationsfontSrc
: Source font file(s) (glob patterns supported)fontDest
: Destination folder for compressed fontsinput
: Text to use for font subsettinginputPath
: File paths to scan for text (glob patterns supported)
runOnceInDev
: Compress fonts in development mode only once