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

@daipeng7/rollup-plugin-iconfont

v3.0.6

Published

Use svg files to build iconfont files(ttf,woff2,woff,eot,svg), css file, js data file and html-preview file.

Downloads

1,101

Readme

@daipeng7/rollup-plugin-iconfont

Use svg files to build iconfont files(ttf,woff2,woff,eot,svg), css file, js data file and html-preview file.

Features:

  • Iconfont output formats: WOFF2, WOFF, EOT, TTF and SVG.
  • Generates CSS file, js data file, html-preview file.
  • Supports webpack and hot reloading at devlopment time. Iconfont files and css file will be rebuilt while any svg file changed or added, then page will refresh.
  • Supports running by nodejs directly.
  • Fixed output files with the same svg files. It means that if the svg files are not changed, all the output files(ttf,woff,css...) will not change, even though you build them again.
  • High iconfont precision.

Install:

npm install -D @daipeng7/rollup-plugin-iconfont

Usage:

You can use it by nodejs directly or use it in webpack

1. Use by nodejs directly:

build/svg2font.js:

var IconfontWebpackPlugin = require("@daipeng7/rollup-plugin-iconfont");
var path = require("path");
var dir = "test/web_project/";
var options = {
  svgs: resolve("src/assets/svgs/*.svg"),
  fontsOutput: resolve("src/style/iconfont/fonts"),
  cssOutput: resolve("src/style/iconfont/index.css"),
  fontName: "custom-iconfont",
  jsOutput: false,
  htmlOutput: false,
  template: "scss",
  // Font loads the absolute path. If not set, the relative path will be automatically calculated based on `cssOutput` and `fontsOutput`.
  // cssFontPath: '',
  // iconFont name prefix
  cssPrefix: "ift",
};

IconfontWebpackPlugin(options).buildStart();

Then you can run this command to build iconfont by svg:

node build/svg2font.js

Or you can set this command to script of package.json, and run it by npm.

2. Use by webpack:

var IconfontWebpackPlugin = require("@daipeng7/rollup-plugin-iconfont");
var dir = "test/web_project/";

module.exports = {
  //... others
  plugins: [
    IconfontWebpackPlugin({
      svgs: path.join(dir, "svgs/*.svg"),
      svgs: resolve("src/assets/svgs/*.svg"),
      fontsOutput: resolve("src/style/iconfont/fonts"),
      cssOutput: resolve("src/style/iconfont/index.css"),
      fontName: "custom-iconfont",
      jsOutput: false,
      htmlOutput: false,
      template: "scss",
      cssFontPath: "style/iconfont/fonts",
      cssPrefix: "ift",
      watch: false,
    }),
  ],
};

Options

svgs (required)

Type: String
File path(s) or glob(s) to svg icons. Recommend to use .svg like this: /src/project/src/.svg, this can watch svgs by directory.

fontsOutput (required)

Type: String
Destination for generated font files (directory).

cssOutput (required)

Type: String
Destination for generated css file (file name).

fontName

Type: String
Default value: iconfont
The font family name (e.g. font-family: 'iconfont').

htmlOutput

Type: String
Default value: [path of cssOutput] + /font-preview.html. Or false value.
Destination for generated html-preview file (file name). If false, no html and js output.

template

Type: String
Default value: css
Type of built in style templates ('css', 'scss', 'scss-mixins') or path to custom template.

formats

Type: Array of String
Default value: ['svg', 'ttf', 'eot', 'woff2', 'woff']
The output iconfont formats.

cssPrefix

Type: String
Default value: fontName
Css className prefix.

jsOutput

Type: String
Default value: undefined.
Path of a js file which contains all svg contents. Optional.

jsPrefix

Type: String
Default value: '/_ eslint-disable _/\n'
Js file content prefix.

cssFontPath

Type: String
Default value: path.relative(path.dirname(options.cssOutput), options.fontsOutput);
Font url path in cssOutput file.

success

Type: Function
Default value: undefined
Iconfonts be created.

watch

Type: Boolean
Default value: undefined
Watch file change.

Please refer to:

https://www.npmjs.com/package/svgicons2svgfont
https://www.npmjs.com/package/svg2ttf
https://www.npmjs.com/package/ttf2eot
https://www.npmjs.com/package/ttf2woff
https://www.npmjs.com/package/ttf2woff2