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 🙏

© 2026 – Pkg Stats / Ryan Hefner

webpack-iconfont-loader

v1.0.0

Published

A Webpack plugin for on-demand loading of iconfont icons

Readme

Webpack + Vue3 图标按需加载插件文档

简介

这是一个专为 Webpack 和 Vue3 项目设计的插件,旨在将阿里巴巴矢量图标库的 iconfont.js 转换为可按需加载的 SVG 图标,帮助项目优化性能并简化图标管理流程。

使用方法

安装插件

通过 npm 进行安装:

npm install webpack-iconfont-loader --save-dev

或者使用 yarn:

yarn add webpack-iconfont-loader --dev

配置插件

在 vue.config.js 文件中添加插件配置:

const {defineConfig} = require('@vue/cli-service')
const webpackIconFontLoader = require('webpack-iconfont-loader')

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    plugins: [
      webpackIconFontLoader({
        moduleId: 'my-icon-font',
        iconFontPath: 'src/iconfont/iconfont.js',
        iconAttrs: {
          width: '16px',
          height: '16px'
        }
      })
    ]
  }
})

图标按需引入

在项目的 Vue 文件中按需引入 SVG 图标:

<template>
  <div class="hello">
    <component :is="IconMenu"></component>
  </div>
</template>

<script>
import {IconMenu} from 'my-icon-font'
// 或者
import IconMenu from 'IconMenu'

export default {
  name: 'HelloWorld',
  setup() {
    return {
      IconMenu
    }
  }
}
</script>

插件参数说明

| 参数名称 | 参数类型 | 是否必填 | 默认值 | 参数描述 | | ------------ | -------- | -------- | ------ | ------------------------------------------ | | moduleId | string | 是 | - | 虚拟模块的 id 名称,用于标识图标模块 | | iconFontPath | string | 是 | - | iconfont.js 文件的路径,指定图标库文件位置 | | iconAttrs | object | 否 | - | 图标属性,可设置图标的样式和属性 |

示例项目结构

your-project/
├── node_modules/
├── public/
├── src/
│   ├── assets/
│   ├── components/
│   ├── iconfont/
│   │   └── iconfont.js
│   ├── main.js
│   └── App.vue
├── .gitignore
├── index.html
├── package.json
└── vue.config.js

注意事项

  • 如果iconfont.js中定义的图标名称为menu,那么图标的引入 id 则是IconMenu,插件自动添加了 Icon 前缀并改成了驼峰写法。
  • 确保 iconfont.js 文件路径配置正确,否则插件无法正常加载图标。
  • 如果需要修改图标样式,可通过调整 iconAttrs 参数实现,也可以在项目中通过 CSS 覆盖样式。