项目作者: cnlon

项目描述 :
Trim useless font formats in `@font-face`
高级语言: JavaScript
项目地址: git://github.com/cnlon/less-plugin-trim-font-face.git
创建时间: 2018-05-07T10:56:07Z
项目社区:https://github.com/cnlon/less-plugin-trim-font-face

开源协议:MIT License

下载


less-plugin-trim-font-face

npm version
js-standard-style

Trim useless formats in @font-face of Less files. Compatible with Less v2 and v3.

Promgrammatic usage

  1. const TrimFontFace = require('less-plugin-trim-font-face')
  2. less.render('You less source', {
  3. plugins: [
  4. new TrimFontFace({
  5. 'iconfont': ['woff']
  6. })
  7. ]
  8. })

It will trim useless font formats but woff if font-family is iconfont in @font-face directives.

For example. If your less source like:

  1. @font-face {
  2. font-family: "iconfont";
  3. src: url('/fonts/iconfont.eot?t=1522658144332');
  4. src: url('/fonts/iconfont.eot?t=1522658144332#iefix') format('embedded-opentype'),
  5. url('/fonts/iconfont.woff') format('woff'),
  6. url('iconfont.ttf?t=1522658144332') format('truetype'),
  7. url('iconfont.svg?t=1522658144332#iconfont') format('svg');
  8. }

You will get output:

  1. @font-face {
  2. font-family: "iconfont";
  3. src: url('/fonts/iconfont.woff') format('woff');
  4. }

MIT