Minify font declarations with PostCSS
npm install postcss-minify-font-values> 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.
``css
h1 {
font:bold 2.2rem/.9 "Open Sans Condensed", sans-serif;
}
p {
font-family: "Helvetica Neue", Arial, sans-serif, Helvetica;
font-weight: normal;
}
`
`css
h1 {
font:700 2.2rem/.9 Open Sans Condensed,sans-serif
}
p {
font-family: Helvetica Neue,Arial,sans-serif;
font-weight: 400;
}
`
#### options
##### removeAfterKeyword
Type: booleanfalse
Default:
Pass true to remove font families after the module encounters a font keyword,sans-serif
for example .
##### removeDuplicates
Type: booleantrue
Default:
Pass false to disable the module from removing duplicated font families.
##### removeQuotes
Type: boolean | (prop: string) => '' | 'font' | 'font-family' | 'font-weight'true
Default:
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][mathias].
Pass a function to determine whether a css variable is one of font, font-family, and font-weight to determine whether the variable needs to remove quotes.
`js``
postcss([ require('postcss-minify-font-values') ])
See [PostCSS] docs for examples for your environment.
See CONTRIBUTORS.md.
MIT © Bogdan Chadkin
[mathias]: https://mathiasbynens.be/notes/unquoted-font-family
[PostCSS]: https://github.com/postcss/postcss
[ci-img]: https://travis-ci.org/cssnano/postcss-minify-font-values.svg
[ci]: https://travis-ci.org/cssnano/postcss-minify-font-values