Minify font declarations with PostCSS
JavaScript
Latest commit ca299a2 Sep 30, 2016 @ben-eb Add a changelog. Closes #6.
Permalink
Failed to load latest commit information.
lib Don't remove functions from font families. May 10, 2016
test Don't remove functions from font families. May 10, 2016
.editorconfig Initial Sep 4, 2015
.eslintrc Initial Sep 4, 2015
.gitignore Initial Sep 4, 2015
.travis.yml Fix travis Feb 19, 2016
CHANGELOG.md Add a changelog. Closes #6. Sep 30, 2016
LICENSE Initial Sep 4, 2015
README.md Update metadata. Sep 30, 2016
index.js Initial Sep 4, 2015
package.json Update metadata. Sep 30, 2016

README.md

postcss-minify-font-values Build Status

Minify font declarations with PostCSS.

This module will try to minimise the font-family, font-weight and font shorthand properties; it can unquote font families where necessary, detect & remove duplicates, and cut short a declaration after it finds a keyword. For more examples, see the tests.

h1 {
  font:bold 2.2rem/.9 "Open Sans Condensed", sans-serif;
}

p {
  font-family: "Helvetica Neue", Arial, sans-serif, Helvetica;
  font-weight: normal;
}
h1 {
  font:700 2.2rem/.9 Open Sans Condensed,sans-serif
}

p {
  font-family: Helvetica Neue,Arial,sans-serif;
  font-weight: 400;
}

API

minifyFontValues([options])

options

removeAfterKeyword

Type: boolean Default: true

Pass false to disable the module from removing font families after it encounters a font keyword, for example sans-serif.

removeDuplicates

Type: boolean Default: true

Pass false to disable the module from removing duplicated font families.

removeQuotes

Type: boolean Default: true

Pass false to disable the module from removing quotes from font families. Note that oftentimes, this is a safe optimisation & is done safely. For more details, see Mathias Bynens' article.

Usage

postcss([ require('postcss-minify-font-values') ])

See PostCSS docs for examples for your environment.

MIT © Bogdan Chadkin