2.0.0 • Published 1 year ago
@peterek/vite-plugin-font v2.0.0
@peterek/vite-plugin-font
Vite plugin for simple use of custom fonts
Use in Vite config file
Minimal configuration
import { join } from 'node:path'
import { font } from '@peterek/vite-plugin-font'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
font({
font: {
name: 'Roboto',
src: join(__dirname, 'assets/Roboto/*.ttf'),
},
})
]
})
Full configuration
import { join } from 'node:path'
import { font } from '@peterek/vite-plugin-font'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
font({
// Base directory for the font files to be accessed from (optional).
// Default: `UserConfig['base'] + 'fonts'`
base: '/',
// Font definitons. It can be defined as single object or as list of configurations
font: [
{
// Font name to be referenced by css rule e.g.: `font-family: Roboto;`
name: 'Roboto',
// Absolute path to the font sources using glob pattern
src: join(__dirname, 'assets/Roboto/*.ttf'),
// The `font-display` descriptor used for each font-face (optional). Default: 'auto'
display: 'auto',
},
],
// Location where inject link tags to (optional). Default: 'head-prepend'
injectLinkTo: 'head-prepend',
// Location where inject link tags to (optional). Default: 'head'
injectStyleTo: 'head',
// Prefetch fonts. If true, takes precedence over preload option (optional). Default: `false`
prefetch: false,
// Preload fonts (optional). Default: `false`
preload: true,
})
]
})
2.0.0-0
1 year ago
2.0.0
1 year ago
1.2.0
2 years ago
1.2.0-0
2 years ago
1.2.2
2 years ago
1.2.1
2 years ago
1.1.9
2 years ago
1.1.8
2 years ago
1.1.7
2 years ago
1.1.6
2 years ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago
0.0.0
2 years ago