1.0.7 • Published 12 months ago
@nartallax/icon-font-tool v1.0.7
Icon font tool
A tool to work with icon fonts.
Very far from "swiss army knife of icon tools"; more like "a tool that fits just my exact needs".
Install
npm install --save-dev @nartallax/icon-font-toolUse
Full list of options is available at
./node_modules/.bin/icon-font-tool --help...but here's an example:
./node_modules/.bin/icon-font-tool \
--svg-dir ./icons \
--font-path target/my_icon_font \
--ts-path target/icon_font.ts \
--css-path target/icon_font_style.cssCommand above will:
- take all SVGs in
./iconsdirectory; - Make a
woff2font out of it (there's option to control formats) and put it in./target/my_icon_font.woff2; - Generate CSS file with classes related to icons and put that CSS file at
./target/icon_font_style.css; - Generate TS file that will import CSS file and export const enum with all the icons.
As you can see, this tool expects that your build process supports CSS importing. The idea behind all of those steps is that you can just import icons from TS file and let builder do all the work regarding delivery of the fonts/styles.
If your CSS file ends with .module.css, then TS file will look a bit different - instead of const enum, it will export an object under the same name. That's not as optimal as const enum, but will work the same way, and if you want names of the icons to be mangled - you can go that route.