Skip to content

Instantly share code, notes, and snippets.

@fernandofleury
Created January 13, 2016 18:35
Show Gist options
  • Save fernandofleury/550051bf15fdc2eb954f to your computer and use it in GitHub Desktop.
Save fernandofleury/550051bf15fdc2eb954f to your computer and use it in GitHub Desktop.
glyph css generation using postcss for https://www.npmjs.com/package/gulp-iconfont
import postcss from 'postcss';
import fs from 'fs';
export default (glyphs) => {
let stylesheet = postcss.root();
glyphs.forEach((glyph) => {
let rule = postcss.rule({
selector: `.icon-${glyph.name}`
});
let decl = postcss.decl({
prop: 'content',
value: `\\${glyph.unicode[0].charCodeAt(0).toString(16).toUpperCase()}`
});
stylesheet.append(rule.append(decl));
});
fs.writeFileSync('dist/icons.css', stylesheet.toResult().css);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment