UNPKG

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