1.1.0 • Published 7 years ago

google-webfonts-webpack-plugin v1.1.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

Google Webfonts Webpack Plugin

Download Google fonts to webpack build folder using google-webfonts-helper or use CDN to integrate with html-webpack-plugin.

WIP


Install

npm install google-webfonts-webpack-plugin

Usage

/webpack.config.js

const GoogleWebfontsPlugin = require("google-webfonts-webpack-plugin")

module.exports = {
	"entry": "index.js",
	/* ... */
	plugins: [
		new GoogleWebfontsPlugin({
			fonts: [
				{ family: "Source Sans Pro" },
				{ family: "Roboto", variants: [ "400", "700italic" ] }
			]
			/* ...options */
		})
	]
}

Options

new GoogleWebfontsPlugin(options: Object)
NameTypeDefaultDescription
fontsFontObject[]-Configuration generated by http://fontello.com.
nameString"icons"Module name.
filenameString"fonts.css"Css file name.
pathString"font/"Relative path to fonts directory. If path is undefined fonts are not downloaded, the css file is generated with Google hosted font files.
localBooleantrueWether to use google-webfonts-helper API or just link to Google Fonts hosted css. If this option is set to false this plugin just adds the css url to html-webpack-plugin (if present).
formatsArray[ "eot", "woff", "woff2", "ttf", "svg" ]Font formats to download.
apiUrlString"https://google-webfonts-helper.herokuapp.com/api/fonts"google-webfonts-helper API url.

FontObject

NameTypeDefaultDescription
familyString-Font family1.
variantsArray-Font variants according to google-webfonts-helper (e.g.: [ "italic", "500", "700italic" ]).
subsetsArray-Font subsets according to google-webfonts-helper (e.g.: [ "latin", "greek" ]).
formatsArray-Font formats to download. Defaults to options.formats.