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

icon-loader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icon-loader

I feel stupid for creating yet another font loader, but here it is.

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

icon-loader 😐

I feel stupid for creating yet another font loader, but here it is.

But why?

I wanted a font loader to:

  • extract a subset of glyphs
  • convert TTF to other formats
  • not haphazardly write files to my filesystem
  • require no additional setup

Apparently, you can only choose two.

Usage

Install this loader and fontmin:

$ npm install --save-dev icon-loader fontmin

Hook it up somewhere in your webpack config:

// webpack config
{
  test: /\.(eot|ttf|woff2?)(\?.*)?$/,
  use: [ 'file-loader', 'icon-loader' ] // or url-loader
}

Import your font and use the glyphs= query option to select the glyphs to extract from your font. In SCSS you can of course build your list of glyphs programmatically as well. Here's an example for Font Awesome:

@import '~font-awesome/scss/_variables.scss';

/* the glyph= query parameter is used by the loader to determine which glyphs to extract */
/* $fa-font-path and $fa-var-meh-o are variables defined by font-awesome */

$fa-font-path: '~font-awesome/fonts';
$fa-font-query: 'v=#{$fa-version}&glyphs=#{unquote($fa-var-meh-o)}';

@font-face {
  font-family: 'FontAwesome';
  src: url('#{$fa-font-path}/fontawesome-webfont.eot?#{$fa-font-query}');
  src: url('#{$fa-font-path}/fontawesome-webfont.eot?#{$fa-font-query}') format('embedded-opentype'),
    url('#{$fa-font-path}/fontawesome-webfont.woff?#{$fa-font-query}') format('woff'),
    url('#{$fa-font-path}/fontawesome-webfont.ttf?#{$fa-font-query}') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@import '~font-awesome/scss/_mixins.scss';
@import '~font-awesome/scss/_core.scss';

Legalese

MIT and stuff

FAQs

Package last updated on 16 Aug 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