All Projects → jeerbl → Webfonts Loader

jeerbl / Webfonts Loader

Licence: mit
Make an icon font from SVGs!

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Webfonts Loader

Phosphor React
A flexible icon family for React
Stars: ✭ 97 (-36.6%)
Mutual labels:  svg, svg-icons, icon-font
Boxicons
High Quality web friendly icons
Stars: ✭ 1,104 (+621.57%)
Mutual labels:  svg, svg-icons, icon-font
Svgtofont
Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font.
Stars: ✭ 149 (-2.61%)
Mutual labels:  ttf, svg-icons, icon-font
Phosphor Icons
A flexible icon family for the web
Stars: ✭ 56 (-63.4%)
Mutual labels:  svg, svg-icons, icon-font
Icons
The premium icon font for @uiwjs Component Library. https://uiwjs.github.io/icons
Stars: ✭ 99 (-35.29%)
Mutual labels:  svg, svg-icons, icon-font
Coreui Icons
CoreUI Free Icons - Premium designed free icon set with marks in SVG, Webfont and raster formats
Stars: ✭ 1,813 (+1084.97%)
Mutual labels:  svg, svg-icons, icon-font
React Cassette Player
Simple ReactJS HTML5 audio player component built with SVG icons from The Noun Project.
Stars: ✭ 93 (-39.22%)
Mutual labels:  svg, svg-icons
Vivid
a JavaScript library which is built to easily customize and use the SVG Icons with a blaze.
Stars: ✭ 1,797 (+1074.51%)
Mutual labels:  svg, svg-icons
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-31.37%)
Mutual labels:  webpack-loader, svg
Simple Icons
SVG icons for popular brands
Stars: ✭ 12,090 (+7801.96%)
Mutual labels:  svg, svg-icons
Svg Fill Loader
DEPRECATED, use https://github.com/kisenka/svg-mixer/tree/master/packages/svg-transform-loader instead
Stars: ✭ 74 (-51.63%)
Mutual labels:  webpack-loader, svg
Svg Icon
👻 A lightweight library that makes it easier to use SVG icons in your Angular Application
Stars: ✭ 112 (-26.8%)
Mutual labels:  svg, svg-icons
Vectoriconsroundup
A comparison between popular vectorial icon fonts
Stars: ✭ 126 (-17.65%)
Mutual labels:  icon-font, font-icons
Svg Native Viewer
SVG Native viewer is a library that parses and renders SVG Native documents
Stars: ✭ 85 (-44.44%)
Mutual labels:  svg, svg-icons
Svg Autocrop
🚗🌽🔳An NPM module to autocrop and slim down SVGs
Stars: ✭ 80 (-47.71%)
Mutual labels:  svg, svg-icons
Tabler Icons
A set of over 1400 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Stars: ✭ 10,858 (+6996.73%)
Mutual labels:  svg, svg-icons
Svg To Ts
Build performant SVG icon libraries by converting raw SVG files to TypeScript that is optimized for modern tree shaking mechanisms.
Stars: ✭ 131 (-14.38%)
Mutual labels:  svg, svg-icons
Angular Svg Icon
Angular component for inlining SVGs allowing them to be easily styled with CSS.
Stars: ✭ 151 (-1.31%)
Mutual labels:  svg, svg-icons
Svgeez
A Ruby gem for automatically generating an SVG sprite from a folder of SVG icons.
Stars: ✭ 69 (-54.9%)
Mutual labels:  svg, svg-icons
Svgsprit.es
Public endpoint to generate SVG Sprites
Stars: ✭ 73 (-52.29%)
Mutual labels:  svg, svg-icons

webfonts-loader

npm npm Travis license

A Webpack loader that generates fonts from your SVG icons and allows you to use your icons in your HTML.

webfonts-loader uses the webfonts-generator plugin to create fonts in any format. It also generates CSS files so that you can use your icons directly in your HTML, using CSS classes.

Installation

npm install webfonts-loader

Usage

An example of usage can be found in the test/ directory of this repository.

Webpack rule

Add this rule to your Webpack config:

{
  test: /\.font\.js/,
  use: [
    MiniCssExtractPlugin.loader,
    {
      loader: 'css-loader',
      options: {
        url: false
      }
    },
    'webfonts-loader'
  ]
}

So that each font configuration file will be loaded using this rule.

Loader options

You can provide options objects to configure the loader behaviour:

{
  test: /\.font\.js/,
  use: [
    MiniCssExtractPlugin.loader,
    {
      loader: 'css-loader',
      options: {
        url: false
      }
    },
    {
      loader: 'webfonts-loader',
      options: { ... }
    }
  ]
}

Available options are:

publicPath, String

This is the URL prefix for generated links (e.g. /static/ or https://cdn.project.net/). Should typically match Webpack's config.output.publicPath.

Any font config option

If you pass types, fileName or any other font config option, it will be used as a default (unless overriden in font config file).

The font configuration file

Description

The config file allows you to specify parameters for the loader to use. Here is an example configuration file:

// myfont.font.js
module.exports = {
  'files': [
    './myfont/*.svg'
  ],
  'fontName': 'myfonticons',
  'classPrefix': 'myfonticon-',
  'baseSelector': '.myfonticon',
  'types': ['eot', 'woff', 'woff2', 'ttf', 'svg'],
  'fileName': 'app.[fontname].[hash].[ext]'
};

Then you have to require the configuration file:

// entry.js
require('./myfont.font');

The loader will then generate:

  • CSS with the base and class prefix
  • Font files for the SVG icons

All font configuration options

baseSelector, String

The base CSS selector, under which each icon class is to be created. See webfonts-generator#templateOptions

classPrefix, String

The prefix to be used with each icon class. See webfonts-generator#templateOptions

cssTemplate, String

See webfonts-generator#cssTemplate

cssDest, String

See webfonts-generator#cssDest

embed, Boolean

If true the font is encoded in base64 and embedded inside the @font-face declaration, otherwise font files are written to disk. Default: false

scssFile, Boolean

If true, the build process will export a .scss file in the same path as the .css file. Default: false

hashLength, Number

Optional. The length of hash in fileName. Min: 8 Max: 32 Default: 20

fileName, String

The generated font file names. These elements can be used:

  • [fontname]: the value of the fontName parameter
  • [ext]: the extension of the font file being generated (eot, ...)
  • [hash]: the hash of the current compilation
  • [chunkhash]: the hash of the SVG files

This option can be also configured globally in the webpack loader options.

emitCodepoints, Array (with shorthand versions of Boolean, String and Object)

Optional. The generated codepoints file names.

Examples:

  • emitCodepoints: true: emits a javascript file named [fontname].codepoints.js in the web (default) format
  • emitCodepoints: '[fontname].codepoints.fonts.js': emits a javascript file named [fontname].codepoints.fonts.js in the commonjs format
  • emitCodepoints: { fileName: '[fontname].codepoints.json', type: 'json'] }: emits a file named [fontname].codepoints.json in the json format
  • emitCodepoints: [{ fileName: '[fontname].codepoints.json', type: 'json'] }, { fileName: '[fontname].codepoints.js', type: 'web'] }, { fileName: '[fontname].codepoints.inc.js', type: 'web'] }]: emits three files with their respective names and types

These are the existing formats:

  • web: (default): generates a file containing the array of codepoints in a format suitable for inclusion in html pages.

Example (for a font named myfonticons):

if (typeof webfontIconCodepoints === 'undefined') {
  webfontIconCodepoints = {};
}
webfontIconCodepoints["myfonticons"] = {"alert":61697,"arrow-down":61698,"arrow-left":61699};
  • commonjs: generates a file containing the array of codepoints in the commonjs format, for use with require.
module.exports = {"alert":61697,"arrow-down":61698,"arrow-left":61699}
  • json: generates a file containing the array of codepoints in the JSON format.
{"alert":61697,"arrow-down":61698,"arrow-left":61699,"arrow-right":61700,"arrow-small-down":61701}

These elements can be used in the filename:

  • [fontname]: the value of the fontName parameter
  • [chunkhash]: the hash of the SVG files

This option can be also configured globally in the webpack loader options.

files, Array

See webfonts-generator#files

fontName, String

See webfonts-generator#fontname

formatOptions, Object

See webfonts-generator#formatoptions

rename, Function

See webfonts-generator#rename

types, Array

See webfonts-generator#types

dest, String

See webfonts-generator#dest

html, Boolean

See webfonts-generator#html

htmlDest, String

See webfonts-generator#htmldest

ligature, Boolean

See webfonts-generator#ligature

cssFontsUrl, String (before cssFontsPath)

See webfonts-generator#cssfontspath

htmlTemplate, String

Example

...
htmlTemplate: path.resolve(__dirname, 'src/html.hbs'),
...

See webfonts-generator#htmltemplate

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].