postcss-minify-font-values

Minify font declarations with PostCSS

MIT 48 个版本
安装
npm install postcss-minify-font-values
yarn add postcss-minify-font-values
pnpm add postcss-minify-font-values
bun add postcss-minify-font-values
README

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: false

Pass true to remove font families after the module 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 | (prop: string) => '' | 'font' | 'font-family' | 'font-weight' 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.

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.

Usage

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

See PostCSS docs for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Bogdan Chadkin

版本列表
8.0.1 2026-06-11
8.0.0 2026-05-06
7.0.3 2026-05-02
7.0.2 2026-04-20
7.0.1 2025-05-06
7.0.0 2024-04-24
6.1.0 2024-03-20
6.0.3 2024-03-06
6.0.2 2024-02-24
6.0.1 2023-12-14
6.0.0 2023-03-27
5.1.0 2022-03-01
5.0.4 2022-02-07
5.0.3 2022-01-23
5.0.2 2022-01-07
5.0.1 2021-05-19
5.0.0-rc.2 2021-03-15
5.0.0-rc.1 2021-03-05
5.0.0-rc.0 2021-02-19
5.0.0 2021-04-10
4.0.2 2018-09-25
4.0.1 2018-09-24
4.0.0-rc.2 2017-08-06
4.0.0-rc.0 2017-06-01
4.0.0 2018-07-04
1.0.5 2016-05-10
1.0.4 2016-04-30
1.0.3 2016-02-19
1.0.2 2015-10-08
1.0.1 2015-09-07
1.0.0 2015-09-04