vite-plugin-literals-collector
v1.2.0
Published
Literals collector for Vite
Downloads
17
Readme
vite-plugin-literals-collector
A plugin for Vite to collect all wanted matching characters.
You can use this plugin to collect all wanted matching characters in your project, and then use them to generate a subset font file or something else.
Usage
Install
$ yarn add -D vite-plugin-literals-collector
# or npm i -D vite-plugin-literals-collector
Add it to vite.config.js
// vite.config.js
import { CJK, literalsCollector } from 'vite-plugin-literals-collector'
const onResult = (result) => {
console.log(result)
}
export default {
plugins: [
literalsCollector({
target: CJK,
onResult
})
],
}
Options
interface Options {
/**
* included filed or folder, defaults to [/\.tsx?$/, /\.jsx?$/]
*/
include?: FilterPattern
/**
* excluded files or folder, defaults to undefined
*/
exclude?: FilterPattern
/**
* wanted matching characters
*/
target?: FilterPattern
/**
* onResult logger, defaults to (final: string[]) =>
* console.log(`* LiteralsCollector: collected ${final.length} characters`)
*/
formatter?: (result: string[]) => void
/**
* result callback, defaults to undefined
*/
onResult?: (result: string[]) => void
}
Thanks
- antfu/vite-plugin-md, I learned how to write a vite-plugin from this repo.