postcss-font-display

PostCSS plugin add font-display css rule


Keywords
postcss, css, postcss-plugin, font-display
License
MIT
Install
npm install postcss-font-display@0.3.0

Documentation

PostCSS Font Display Build Status

PostCSS plugin to automatically add font-display css rule.

@font-face {
    /* Input example */
    font-family: 'My Font';
}
@font-face {
    /* Output example */
    font-family: 'My Font';
    font-display: swap;
}

Install

With npm do:

npm install postcss-font-display --save

Usage

postcss([ require('postcss-font-display')({ display: 'swap', replace: false }) ])

Advanced usage

postcss([ require('postcss-font-display')([
  { display: 'swap', replace: false },
  { test: 'FontAwesome', display: 'block' },
]) ])

Options

Option Type Default Description
test RegExp false Text pattern for font-family css rule
display String swap Value for new font-display css rule
replace Boolean false Replace exists font-display rule

See PostCSS docs for examples for your environment.