npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@veno-ui/vite-plugin-icons

v0.4.12

Published

Vite icons plugin for Veno UI

Downloads

2

Readme

Veno UI 的 Vite 图标插件

NPM version

按需导入图标作为组件。

特性

  • 🤹 任意图标集 - 超过 10,000 个图标、徽标、表情符号等的 100 多个流行图标集。由 Iconify 提供支持。
  • ☁️ 按需 - 仅捆绑您真正使用的图标。
  • 📥 自动加载目录 - 加载目录下的图标文件作为自定义图标。
  • 📲 自动导入 - 直接在模板中使用,匹配组件属性自动替换。

用法

模板中组件属性的静态替换

仅支持字符串的静态替换

<ve-button icon="mdi-close" />

实际会被替换成(此处只是演示,实际不会替换成 SFC 格式)

<script lang="ts" setup>
  import __veno_ui_icons_0 from '~veno-ui/icons/mdi/close'
</script>

<template>
  <ve-button :icon="__veno_ui_icons_0" />
</template>

加载自定义图标

默认自动加载 src/icons 目录下的所有 svg 结尾的文件,使用 ~veno-ui/icons 加载。

import { createVeno } from 'veno-ui'
import icons from '~veno-ui/icons'
const veno = createVeno({
  icons: {
    aliases: icons,
  },
})

安装

插件

npm i -D @veno-ui/vite-plugin-icons

图标数据

我们使用 Iconify 作为图标数据源(支持 100 多个图标集)。

您有两种安装方式:

安装全部插件

npm i -D @iconify/json

@iconify/json (~120MB) 包括来自 Iconify 的所有图标集。

按图标集安装

如果您只想使用几个图标集而不想下载整个集合,您也可以使用 @iconify-json/[collection-id] . 例如,要安装 Material Design Icons ,你可以这样做:

npm i -D @iconify-json/mdi

配置

import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Icons from '@veno-ui/vite-plugin-icons'

export default defineConfig({
  plugins: [
    Icons({
      // 选项
    }),
    Vue()
  ],
})

可用选项

所有可用选项看types.ts

export interface Options
{
  /**
   * @zh 引入文件的过滤模式
   * @en RegExp or glob to match files to be transformed
   *
   * @default [/\.vue$/, /\.vue\?vue/]
   */
  include?: FilterPattern

  /**
   * @zh 排除文件的过滤模式
   * @en RegExp or glob to match files to NOT be transformed
   *
   * @default [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]
   */
  exclude?: FilterPattern

  /**
   * @zh 识别传入组件的属性值替换成图标组件
   *
   * @default
   *
   *  [
   *     { component: 'VeAlert', props: ['icon', 'closeIcon'] },
   *     { component: 'VeAvatar', props: ['icon'] },
   *     { component: 'VeBadge', props: ['icon'] },
   *     { component: 'VeButton', props: ['icon', 'prependIcon', 'appendIcon'] },
   *     { component: 'VeIcon', props: ['icon'] },
   *     { component: 'VeLink', props: ['icon', 'prependIcon', 'appendIcon'] },
   *     { component: 'VeListItem', props: ['prependIcon', 'appendIcon'] },
   *     { component: 'VeListGroup', props: ['collapseIcon', 'expandIcon'] },
   *     { component: 'VeFormControl', props: ['appendIcon'] },
   *     { component: 'VeInput', props: ['appendIcon', 'appendInnerIcon', 'clearIcon', 'prependInnerIcon', 'prefixIcon', 'suffixIcon'] },
   *     { component: 'VeSelect', props: ['appendIcon', 'appendInnerIcon', 'clearIcon', 'prependInnerIcon', 'prefixIcon', 'suffixIcon'] },
   *     { component: 'VeDatePicker', props: ['appendIcon', 'appendInnerIcon', 'clearIcon', 'prependInnerIcon', 'prefixIcon', 'suffixIcon'] },
   *   ]
   */
  replaces?: { component: string, props: string[] }[],

  /**
   * @zh 用于搜索图标的相对目录路径
   * @en Relative paths to the directory to search for icons
   *
   * @default 'src/icons'
   */
  dirs?: string | string[]

  /**
   * @zh 图标的有效文件扩展名
   * @en Valid file extensions for icons
   *
   * @default ['svg']
   */
  extensions?: string | string[]

  /**
   * @zh 搜索子目录
   * @en Search for subdirectories
   *
   * @default true
   */
  deep?: boolean

  /**
   * @zh 传递给 svgo 的选项
   * @en Options passed to Svgo
   *
   * @default { plugins: ['preset-default', 'removeViewBox', 'removeDimensions'] }
   */
  svgoOptions?: OptimizeOptions
}