KusStar / vite-plugin-literals-collector

A plugin for Vite to collect all wanted matching characters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vite-plugin-literals-collector

A plugin for Vite to collect all wanted matching characters.

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 [/\.ts$/, /\.js$/]
   */
  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

About

A plugin for Vite to collect all wanted matching characters

License:MIT License


Languages

Language:TypeScript 96.9%Language:JavaScript 3.1%