Skip to content

Latest commit

 

History

History
68 lines (51 loc) · 1.26 KB

README.zh_CN.md

File metadata and controls

68 lines (51 loc) · 1.26 KB

vite-plugin-color

自动改变指定颜色并输出主题包

用法

安装

node version: >= 14.0.0

vite version: >= 2.0.0

yarn add vite-plugin-color -D

or

npm i vite-plugin-color -D

使用

vite.config.js添加插件配置

// vite.config.js
import viteColor from 'vite-plugin-color'

export default {
  plugins: [
    viteColor([
      {
        extract: ['#eee'],
        output: 'themes/triple-e.css',
        injectTo: 'head'
      }
    ])
  ]
}

Options

参数可以是单个对象,也可以是对象数组

export interface propType {
  // 需要抽取的色值,暂不支持内联样式或styled
  extract: string[]
  // 对匹配内容的处理函数
  transform?: (code: string) => string
  // 外部css文件链接,如`cdn`
  external?: string[]
  // 文件输出路径
  output?: string
  // 是否压缩 @default true
  minify?: boolean
  // 压缩参数,遵循`clean-css`
  minifyOptions?: OptionsPromise
  // 生产环境自动注入加载的 css, 支持自定义,遵循`vite HtmlTagDescriptor`
  injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend' | HtmlTagDescriptor
}

export type optionType = Array<propType> | propType

License

MIT