iconfont-hero-cli是一个通过配置,就可以生成结构化图标schema的小工具
npm install -g iconfont-hero-cli
// tree -L 2 -I node_modules
├── README.md
├── example
│ └── vscode-iconfont.json
├── index.js
├── package-lock.json
├── package.json
└── yarn.lock
// vscode-iconfont.json
{
"element": {
"ttf": "https://unpkg.com/element-ui@2.15.9/lib/theme-chalk/fonts/element-icons.ttf",
"css": "https://unpkg.com/element-ui@2.15.9/lib/theme-chalk/index.css"
},
"vant": {
"ttf": "https://at.alicdn.com/t/font_2553510_iv4v8nulyz.ttf",
"css": "https://unpkg.com/vant@3.5.4/lib/index.css"
}
}
iconfont-hero -c ../example/vscode-iconfont.json
// iconfont-hero -c ../example/vscode-iconfont.json -f #ffffff (svg -> fill)
// iconfont-hero -c ../example/vscode-iconfont.json -w 20 (svg -> width)
// .iconfont/schema.json
{
"el-icon-ice-cream-round": {
"content": "\"\\e6a0\"",
"svg": "data:image/svg+xml;utf8,....",
"type": "element"
},
"el-icon-ice-cream-square": {
"content": "\"\\e6a3\"",
"svg": "data:image/svg+xml;utf8,....",
"type": "element"
},
...
}