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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sass-web-fonts

v2.1.0

Published

A Sass mixin to allow easy, efficient usage of Google Web Fonts.

Readme

Sass Web Fonts

A Sass mixin to allow easy, efficient usage of Google Web Fonts.

You can clone this repo and include _web-fonts.scss in your project manually, or you can install the sass-web-fonts package from npm or Bower.

Upgrading from a previous version of Sass Web Fonts

Sass Web Fonts 2.x introduces breaking changes from 1.x. If you're upgrading from Sass Web Fonts 1.x, read the upgrading guide. It's very easy. :)

Usage

First, import Sass Web Fonts like this:

@import "web-fonts";

Installing with npm and using a node-based task-runner

  1. Add Sass-Web-Fonts as a dependency:

    npm install --save sass-web-fonts
  2. You’ll need to add Sass-Web-Fonts to your node-sass includePaths option. Commonly in this way: require("sass-web-fonts").includePaths. But specifically you have to refer to the framework you are using.

With Grunt

const sass = require( "node-sass" );

module.exports = function( grunt ) {
	require( "load-grunt-tasks" )( grunt );

	grunt.initConfig( {
		sass: {
			options: {
				implementation: sass,
				sourceMap: false,
				outputStyle: "compressed",
				sourceComments: false,

				includePaths: [
					//require( "module-one" ).includePaths,
					//require( "module-two" ).includePaths,
					require( "sass-web-fonts" ).includePaths
				]
			},
			public: {
				files: {
					"master.css": "master.scss"
				}
			}
		}
  } );
};

With Gulp

var gulp = require( "gulp" );
var sass = require( "gulp-sass" );

gulp.task( "sass", function () {
  gulp.src( "input.scss" )
    .pipe( sass( {
      includePaths: require( "sass-web-fonts" ).includePaths
    } ) )
    .pipe( gulp.dest( "output.css" ) );
} );

Using with libsass

If you are using libsass, you can't pass the result of web-fonts-url() directly into @import url(). You have to store it in a variable first. This is due to the compiler not supporting importing urls from functions.

// This won't work with libsass
@import url(web-fonts-url("Open Sans"));

// This will work with libsass
$url: web-fonts-url("Open Sans");
@import url($url);

Importing a single font

@import url(web-fonts-url("Open Sans"));

Specifying font variant

@import url(web-fonts-url(("Open Sans": "bold")));

Multiple variants

@import url(web-fonts-url(("Open Sans": ("500", "600 italic"))));

Multiple fonts

@import url(web-fonts-url("Open Sans", ("Ubuntu": ("400", "italic"))));

Protocols

By default, the web-fonts mixin will attempt to load fonts with the same protocol that was used to access the stylesheet it was called in. However, in some circumstances, most notably when the stylesheet was loaded as a local file (using a file:// url), this will not work. In this situation, it is possible to override the automatic protocol detection by setting the $web-fonts-protocol variable prior to calling the mixin.

Example

$web-fonts-protocol: "https"; // fonts will be loaded over HTTPS from here on.
@import url(web-fonts-url("Open Sans"); // uses HTTPS);

Extra parameters

To add additional parameters to the web fonts URL, you can override the $web-fonts-params variable with a map containing the extra URL params. For example, you can use it to specify character subsets:

$web-fonts-params: (subset: "latin,latin-ext");
@import url(web-fonts-url("Open Sans"));
/* Generated CSS */
@import url("//fonts.googleapis.com/css?subset=latin%2Clatin-ext&family=Open%20Sans");

A list of available parameters can be found in the Google Web Fonts documentation.

Testing

Development of this mixin uses SassUnit for unit tests. To run the tests after making a change to the mixin, do this:

$ bundle install
$ bundle exec sassunit

Codeship Status for alyssais/Sass-Web-Fonts

Troubleshooting

If you get a Sass::SyntaxError when using the library, you probably need to update Sass. See issue #7 for more information.


Requires Sass 3.3 or later version. Pull requests welcome.