Direct iconfont from SVG icon files.
npm i rapidjs-org/plugin--iconfont
__rjs.plugin.json
{
"package": "@plugins.rapidjs.org/iconfont"
}
└─ /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>
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