1.2.0 • Published 3 months ago

vite-plugin-literals-collector v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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

LICENSE

MIT

1.2.0

3 months ago

1.1.1

3 months ago

1.1.0

3 months ago

1.1.2

3 months ago

1.0.0

3 years ago

0.1.0

3 years ago