Skip to content

rapidjs-org/plugin--iconfont

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iconfont   rJS Plugin

Direct iconfont from SVG icon files.

Install

npm i rapidjs-org/plugin--iconfont

__rjs.plugin.json

{
  "package": "@plugins.rapidjs.org/iconfont"
}

Use

└─ /src …
   └─ /iconfont
      ├─ __rjs.plugin.json
      └─ /icons
         ├─ 00-plus.svg
         ├─ 01-chevron.svg
         └─ 02-cross.svg

public/style.css

@font-face {
  font-family: "iconfont";
  src: url("/iconfont.ttf");
}

.icon::before {
  font-family: "iconfont";
}

.icon--plus::before {
  content: "\E000"
}
.icon--chevron::before {
  content: "\E001"
}
.icon--cross::before {
  content: "\E002"
}

public/index.html

<html>
  <head>
    <link rel="stylesheet" href="/style.css">
  </head>
  <body>
    <a href="/new" class="icon icon--plus"></a>
  </body>
</html>

Configure

By default, the plugin emits the iconfont to /iconfont.ttf. An alternative can be specified via outPath.

__rjs.plugin.json

{
  "package": "@plugins.rapidjs.org/iconfont",
  "config": {
    "outPath": "assets/fonts/my-iconfont"
  }
}

© Thassilo Martin Schiepanski