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

svg2iconfont-webpack

v1.1.0

Published

a webpack plugin for svg to iconfont

Downloads

5

Readme

Svg2Iconfont-webpack

A webpack plugin for svg transform to iconfont automatically.🎉

why use?

English:

  1. You can package all svg files to iconfont bundle.
  2. You can use it in your code by setting ClassName(the same as filename) directly without any import or require.
  3. All process is automatic, you don't care about anything;

中文:

  1. 你可以根据指定资源路径,打包所有的svg文件,统一生成一份iconfont文件
  2. 整个流程都是自动的,统一生成的文件也是自动引入的,你不用另外的import或者require,你只需要启动你的项目(npm start),即可在你的代码里对应文件名直接设置ClassName,即可显示ICON图标。

Getting Started

First of all, install the module:

npm i svg2iconfont-webpack

⚠️ Warning: The webpack-plugin Svg2Iconfont-webpack require webpack v4, not support webpack v3.

Usage

const Svg2IconfontWebpack = require("svg2iconfont-webpack");
const path = require('path');

const resolve = oppositePath => {
  return path.resolve(__dirname, oppositePath);
};

module.exports = {
  plugins: [
    new Svg2IconfontWebpack({
      // 你的资源文件夹根目录
      // your svg assets root url
      assetsPath: resolve("./assets/icon"),
      // output(输出配置)
      output: {
        // 输出字体文件的名称(ttf, otf, etc...)
        // font-lib name => myIconfont
        fileName: "myIconfont",
        // 引入CSS文件的名称
        // import css modules name
        cssFileName: "iconfont-web"
      },
      
      // font options(字体配置)
      fontOptions: {
        // icon类名的前缀
        cssPrefix: 'iconfont',
        // 图标的基准大小
        // icon basic size
        fontSize: 32,

        // 图标的font-family
        // font-family
        fontFamily: 'iconfont'
      },

      // 是否开启图标列表预览模式
      // 预览模式默认监听在本地3000端口,若端口占用依次递增
      preview: false 
    })
  ]
}

And you can show the icons by setting ClassName(From Filename), the same name from Filename, including the path,but format to '-' sign.

<!-- 你可以通过设置你对应svg文件的文件名(不带svg后缀名),来达到显示图标的目的,注意,如果你的文件是嵌套在文件夹里面的,请输入文件夹 + 文件名的方式来对应显示,分隔符是“-”而不是“/” -->
<!-- 前缀默认是iconfont,用分隔符和图标名间隔开 -->
<!-- if you want to show the "my-icon-file-name.svg" ICON -->
<!-- the className below represent the icons -->
<!-- `iconfont` from "options.fontOptions.cssPrefix" -->
<i class="iconfont-my-icon-file-name"></i>

Then you will see ICON appeared:

plugin-desc

OR You can set its unicode by your own className(First, you should know the ICON's unicode)

<!-- add class "icon-iconfont" -->
<!-- `icon-iconfont` from "options.className" -->
<i class="my-icon-class"></i>

Css

/* your icon class */
.my-icon-class::after {
  /* your icon unicode */
  content: "\0e602"; 
}

LICENSE

MIT