Socket
Book a DemoInstallSign in
Socket

google-fonts-plugin

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-fonts-plugin

Webpack plugin that downloads fonts from Google Fonts and encodes them to base64.

5.0.2
latest
Source
npmnpm
Version published
Weekly downloads
1.1K
-4.68%
Maintainers
1
Weekly downloads
 
Created
Source

Google Fonts Plugin

GitHub license npm CircleCI Codecov

Buy Me A Coffee

Webpack plugin that downloads fonts from Google Fonts and encodes them to base64.

Supports various font formats, currently eot, ttf, woff and woff2.

Exports to format specific css files, which you can serve to your clients.

Note: Current version works with Webpack 4. For webpack 3, use version 1.0.3

Install

npm install --save-dev google-fonts-plugin

Usage

webpack.config.js
const GoogleFontsPlugin = require('google-fonts-plugin')

module.exports = {
  plugins: {
    new GoogleFontsPlugin({
        /* options */
    })
  }
}
webpack.config.js
const GoogleFontsPlugin = require('google-fonts-plugin')

module.exports = {
  plugins: {
    new GoogleFontsPlugin('path/to/config.json')
  }
}

Options

Plugin supports configuration in javascript object, json file and also in your package.json.

NameTypeDefaultDescription
fontsFont[]RobotoDefines which fonts and it's variants and subsets to download.
formatsString[]woff, woff2Specifies which formats to download. Valid options are eot, ttf, woff and woff2.
encodeBooleantrueWhether should encode to base64.
cacheBooleantrueWhether FS caching should be checked before sending requests.
fontDisplayStringswapWhen encode if false, this will add font-display property. Disables when empty.
filenameString[name].cssDefines filename template. Valid substitutions are [name], [hash], [chunkhash].
statsBooleantrueCollects basic statistics about options. You may opt out at any time by setting this to false
Font object
NameTypeDefaultDescription
familyStringRobotoSets the font family
variantsString[]400, 400i, 700, 700iSets the variants of the font family to download, note that not all fonts have all the possible variants
subsetsString[]latin-extSets the subsets, note that not all fonts are available in all subsets
textStringOnly downloads specific characters contained in the string provided, more information here. Ignores subsets.

Example configuration

config.json
{
	"google-fonts-plugin": {
		"fonts": [
			{
				"family": "Roboto",
				"variants": [
					"400",
					"400i",
					"700",
					"700i"
				],
				"subsets": [
					"latin-ext"
				]
			}
		],
		"formats": [
			"woff",
			"woff2"
		]
	}
}

Note: For Google's material icons, simply set Material Icons as font-family

Note: From version 5.0.0, neon support is dropped to simplify the plugin itself. If you've used neon before, parse it yourself and pass the resulting object to the plugin instead. See release notes for implementation example.

Keywords

google

FAQs

Package last updated on 27 Sep 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.