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

@tomjs/vite-plugin-iconify

v1.2.1

Published

A Vite plugin for handling iconify icon sets in environments without internet access.

Downloads

163

Readme

@tomjs/vite-plugin-iconify

npm node-current (scoped) NPM Docs

English | 中文

vite 插件,用于处理 iconify 图标集,在无法访问公网的环境下使用

安装

# pnpm
pnpm add @iconify/json @tomjs/vite-plugin-iconify -D

# yarn
yarn add @iconify/json @tomjs/vite-plugin-iconify -D

# npm
npm i @iconify/json @tomjs/vite-plugin-iconify --save-dev

使用说明

以 vue/react 项目为例

使用插件

vue示例

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import iconify from '@tomjs/vite-plugin-iconify';

export default defineConfig({
  plugins: [
    vue(),
    iconify({
      resources: ['https://unpkg.com/@iconify/json/json'],
      rotate: 3000,
      local: ['ant-design', 'ep'],
    }),
  ],
});

react示例

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import iconify from '@tomjs/vite-plugin-iconify';

export default defineConfig({
  plugins: [
    react(),
    iconify({
      resources: ['https://unpkg.com/@iconify/json/json'],
      rotate: 3000,
      local: ['ant-design', 'ep'],
    }),
  ],
});

文档

参数

| 参数名 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | selector | string | 'title' | 标签选择器,注入IconifyProviders脚本添加在指定的标签后面 | | resources | string[] | [] | 图标 API 地址,默认带上 https://api.iconify.design | | rotate | number | 750 | 使用下一个主机之前的超时时间(以毫秒为单位) | | timeout | number | 5000 | API 查询被视为失败之前的超时时间(以毫秒为单位) | | local | 'boolean'\|'IconifySet[]'\|IconifyLocal[] | false | 本地图标集配置 |

resources: 你可以添加 npm cdn 或自定义url

  • npmmirror:
    • https://registry.npmmirror.com/@iconify/json/{version}/files/json
    • https://registry.npmmirror.com/@iconify/json/latest/files/json
    • https://registry.npmmirror.com/@iconify/json/2.2.187/files/json
  • jsdelivr:
    • https://cdn.jsdelivr.net/npm/@iconify/json@{version}/json
    • https://cdn.jsdelivr.net/npm/@iconify/json/json
    • https://cdn.jsdelivr.net/npm/@iconify/[email protected]/json
  • unpkg:
    • https://unpkg.com/@iconify/json@{version}/json
    • https://unpkg.com/@iconify/json/json
    • https://unpkg.com/@iconify/[email protected]/json
IconifySet

iconify 图标集,参考 icon setsIcônes

IconifyLocal

配置该参数,会根据 sets 配置,将本地图标集复制到 outDir 目录下

| 参数名 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | sets | IconifySet[] | [] | iconify 图标集 | | base | string | '/' | 同 vite 配置 base 选项 | | outDir | string | 'dist' | 本地输出目录, 默认同 vite 配置 build.outDir 选项 | | path | string | 'npm/@iconify/json@{version}' | 本地输出路径,对应模块url也会替换为该路径 |

使用cli

生成 iconify 图标集数据,用于图标选择等功能使用

  • 以在 package.jsonscripts 中添加 ti ant-design ep --path src/constants
  • 直接运行 pnpm ti ant-design ep --path src/constants
Usage:
  $ ti [...sets]

Commands:
  [...sets]  create icon collection data based on @iconify/json in the project

For more info, run any command with the `--help` flag:
  $ ti --help

Options:
  --path <path>  [string] output file path. (default: src)
  --name <name>  [string] output file name. if tsconfig is exists, default is 'iconify.ts', or is 'iconify.js'
  --type <type>  ["esm" | "cjs"] output file type. (default: esm)
  -h, --help     Display this message
  -v, --version  Display version number

开发

  • 开发环境

    • git
    • node>=16
    • pnpm>=8
  • 首次使用,需要安装依赖,执行如下命令

# 安装依赖
pnpm i
# 编译库
pnpm build
  • 调试 vue 项目,执行如下命令
cd examples/vue
pnpm build
pnpm preview
  • 调试 react 项目,执行如下命令
cd examples/react
pnpm build
pnpm preview