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

iconfont-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iconfont-webpack-plugin

Simple icon font handling for webpack

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4K
decreased by-12.88%
Maintainers
1
Weekly downloads
 
Created
Source

ALPHA

This release is rather for feedback purpose than for production usage.

Icon Font Webpack Plugin

This plugin tries to keep the usage and maintenance of icon fonts as simple as possible.

Installation

npm i --save-dev iconfont-webpack-plugin

Configuration

var IconfontWebpackPlugin = require('iconfont-webpack-plugin');

  // make sure you use the postcss loader:
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!postcss-loader'
      }
    ]
  },
  // add the plugin
  plugins: [
    new IconfontWebpackPlugin()
  ]

Usage

After setting up the plugin your css has now a new feature:
font-icon declarations

a:before {
  font-icon: url('./account.svg');
  transition: 0.5s color;
}

a:hover:before {
  color: red;
}

and it will be compiled into:

@font-face {
  font-family: i96002e;
  src: url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAA.....IdAA==") format('woff');
}

a:before {
  font-family: i96002e;
  content: '\E000';
  transition: 0.5s color;
}

a:hover:before {
  color: red;
}

Should you use icon fonts for everything?

No.

Icon fonts are really good for decorative icons (where the icon is purely ornamental and doesn’t incorporate core meaning or functionality).

For critical icons without fallbacks (like a hamburger menu icon) you should rather use SVGs. But also JPEGs, PNGs and even GIFs have their use cases.

Pick the best solution for your problem - there is no silver bullet. With this plugin it is pretty easy to use pixel images, svgs and font-icons side by side.

When should you use icon fonts over pure SVGs?

SVGs have some disadvantages and lack certain features especially when used inside pseudo elements:

  • CSS-Transform issues in older Internet Explorer versions
  • IE9 - IE 11 scaling issues
  • Fill color doesn't work for background SVG images
  • Inline SVGs are resolved relative to the page not to the css

What about all the rant on icon fonts?

Like all technologies there are disadvantages when using icon fonts.
We tried to apply best practices to solve the main issues for you.

License

This project is licensed under MIT.

Keywords

FAQs

Package last updated on 21 Sep 2016

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