Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webfonts-loader

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webfonts-loader

A WebPack loader to automaticaly generate font files and CSS to make your own icon font

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by3.56%
Maintainers
1
Weekly downloads
 
Created
Source

webfonts-loader

npm Travis license

A 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/,
  loader: ExtractTextPlugin.extract({
    use: [
      'style-loader',
      'css-loader',
      'webfonts-loader'
    ]
  })
}

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

The font configuration file

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.

And there you are - your webfont is done. Now, here is one thing: You can use JavaScript too. A useful thing is, that there are two additional options that I did not mention:

All font configuration options

Keywords

FAQs

Package last updated on 22 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc