Coder Social home page Coder Social logo

mattmakes / google-fonts-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sirpole/google-fonts-plugin

0.0 2.0 0.0 82 KB

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

License: GNU General Public License v3.0

JavaScript 100.00%

google-fonts-plugin's Introduction

Google Fonts Plugin

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 and minified css files, which you can serve to your clients.

Install

npm i -D google-fonts-plugin

Usage

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

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

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

Options

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

Name Type Default Description
fonts Font[] Roboto Defines which fonts and it's variants and subsets to download
formats String[] eot, ttf, woff, woff2 Specifies which formats to download
outputDir String public/fonts Specifies the output directory
encode Boolean true Whether should encode to base64
minify Boolean true Whether should minify resulting css
Font object
Name Type Default Description
family String Roboto Sets the font family
variants String[] 400, 400i, 700, 700i Sets the variants of the font family to download, note that not all fonts have the all the possible variants
subsets String[] latin-ext Sets the subsets, note that not all fonts are available in all subsets

Example configuration

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

google-fonts-plugin's People

Contributors

sirpole avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.