Created
January 13, 2016 18:35
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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