[6a3a178] | 1 | # postcss-minify-font-values [![Build Status][ci-img]][ci]
|
---|
| 2 |
|
---|
| 3 | > Minify font declarations with PostCSS.
|
---|
| 4 |
|
---|
| 5 | This module will try to minimise the `font-family`, `font-weight` and `font` shorthand
|
---|
| 6 | properties; it can unquote font families where necessary, detect & remove
|
---|
| 7 | duplicates, and cut short a declaration after it finds a keyword. For more
|
---|
| 8 | examples, see the [tests](test).
|
---|
| 9 |
|
---|
| 10 | ```css
|
---|
| 11 | h1 {
|
---|
| 12 | font:bold 2.2rem/.9 "Open Sans Condensed", sans-serif;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | p {
|
---|
| 16 | font-family: "Helvetica Neue", Arial, sans-serif, Helvetica;
|
---|
| 17 | font-weight: normal;
|
---|
| 18 | }
|
---|
| 19 | ```
|
---|
| 20 |
|
---|
| 21 | ```css
|
---|
| 22 | h1 {
|
---|
| 23 | font:700 2.2rem/.9 Open Sans Condensed,sans-serif
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | p {
|
---|
| 27 | font-family: Helvetica Neue,Arial,sans-serif;
|
---|
| 28 | font-weight: 400;
|
---|
| 29 | }
|
---|
| 30 | ```
|
---|
| 31 |
|
---|
| 32 | ## API
|
---|
| 33 |
|
---|
| 34 | ### minifyFontValues([options])
|
---|
| 35 |
|
---|
| 36 | #### options
|
---|
| 37 |
|
---|
| 38 | ##### removeAfterKeyword
|
---|
| 39 |
|
---|
| 40 | Type: `boolean`
|
---|
| 41 | Default: `false`
|
---|
| 42 |
|
---|
| 43 | Pass `true` to remove font families after the module encounters a font keyword,
|
---|
| 44 | for example `sans-serif`.
|
---|
| 45 |
|
---|
| 46 | ##### removeDuplicates
|
---|
| 47 |
|
---|
| 48 | Type: `boolean`
|
---|
| 49 | Default: `true`
|
---|
| 50 |
|
---|
| 51 | Pass `false` to disable the module from removing duplicated font families.
|
---|
| 52 |
|
---|
| 53 | ##### removeQuotes
|
---|
| 54 |
|
---|
| 55 | Type: `boolean`
|
---|
| 56 | Default: `true`
|
---|
| 57 |
|
---|
| 58 | Pass `false` to disable the module from removing quotes from font families.
|
---|
| 59 | Note that oftentimes, this is a *safe optimisation* & is done safely. For more
|
---|
| 60 | details, see [Mathias Bynens' article][mathias].
|
---|
| 61 |
|
---|
| 62 | ## Usage
|
---|
| 63 |
|
---|
| 64 | ```js
|
---|
| 65 | postcss([ require('postcss-minify-font-values') ])
|
---|
| 66 | ```
|
---|
| 67 |
|
---|
| 68 | See [PostCSS] docs for examples for your environment.
|
---|
| 69 |
|
---|
| 70 | ## Contributors
|
---|
| 71 |
|
---|
| 72 | See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
|
---|
| 73 |
|
---|
| 74 | # License
|
---|
| 75 |
|
---|
| 76 | MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
|
---|
| 77 |
|
---|
| 78 | [mathias]: https://mathiasbynens.be/notes/unquoted-font-family
|
---|
| 79 | [PostCSS]: https://github.com/postcss/postcss
|
---|
| 80 | [ci-img]: https://travis-ci.org/cssnano/postcss-minify-font-values.svg
|
---|
| 81 | [ci]: https://travis-ci.org/cssnano/postcss-minify-font-values
|
---|