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

aurelia-fontawesome-loader

v1.0.0-beta.1

Published

A webpack loader for aurelia-fontawesome

Downloads

49

Readme

aurelia-fontawesome-loader

A webpack loader for aurelia-fontawesome

Why?

The loader makes it super easy to use the aurelia-fontawesome component with webpack. When the loader is configured properly you can simply write the following in your aurelia views:

<font-awesome-icon icon="coffee"></font-awesome-icon>

or

<font-awesome-icon icon.bind="['fab', 'microsoft']"></font-awesome-icon>

The coffee icon is automatically added as a dependency to the view and the icon is loaded when needed. This ensures that the final produced bundle/chunk only contains the icons that are actually used. Moreover, it also reduces the hassle of adding the icons one-by-one to the font-awesome library.

Installation

Install the loader with npm

$ npm i --save-dev aurelia-fontawesome-loader

How it Works

The loader transforms the html files with the following changes:

  • It adds a <require from="..."></require> for each icon it detects in <font-awesome-icon icon="..."></font-awesome-icon> to ensure that the icon becomes a dependency to the view.
  • It rewrites the icon property such that the fontawesome binding behavior is invoked which ensures that the icon is loaded before it is passed on to the icon property on the element. An example is <font-awesome-icon icon="coffee"></font-awesome-icon> which is rewritten to <font-awesome-icon icon.bind="'coffee' & fontawesome"></font-awesome-icon> See the sample app here for more examples on how the loader works.

Configuration

You can see the sample webpack configuration using the loader here. Two things needs to be configured for the loader to work propertly.

  1. The loader must be used for html files. It needs to run before the html-requires-loader which is included by default in the aurelia-webpack-plugin.
module: {
  rules: [
    {
      test: /\.html$/,
      use: [
        // The order of the loaders are important
        "html-loader",
        "aurelia-webpack-plugin/html-requires-loader",
        "aurelia-fontawesome-loader/loader"
      ]
    }
  ]
}

The loader resolves to the free icon set by default - you can use the loader with the pro option if you have that license. This is easiest done by setting the loader to "aurelia-fontawesome-loader/loader?pro".

  1. Tell the aurelia-webpack-plugin that it should not automatically insert the html-requires-loader:
plugins: [
  new AureliaPlugin({
    noHtmlLoader: true
  })
]
  1. Tell your aurelia app to include the loader binding behavior that brings in icons as needed. Do this by inserting the following in your code during aurelia boot
aurelia.use.plugin(PLATFORM.moduleName('aurelia-fontawesome-loader'))