Commit 9849144f authored by Terion's avatar Terion

use fontello for icons

parent 98bc72a8
gulp = require 'gulp'
gulp.task 'icons', ->
iconfont = require 'gulp-iconfont'
iconfontCss = require 'gulp-iconfont-css'
sass = require 'gulp-sass'
runTimestamp = Math.round( / 1000)
importer = require('gulp-fontello-import')
replace = require('gulp-replace')
fs = require('fs')
gulp.src 'src/img/icons/*.svg'
fontName: 'icons',
path: 'node_modules/gulp-iconfont-css/templates/_icons.scss',
targetPath: '../../css/icons.scss',
fontPath: '../fonts/icons/'
fontName: 'icons',
appendUnicode: true,
formats: ['ttf', 'eot', 'woff', 'svg'],
timestamp: runTimestamp
.on('finish', ->
# this is very hacky, but we don't have a sync interface here
# and there is no event on SCSS file created
# so we simply wait while FS write will be finished
setTimeout ( ->
gulp.src 'build/css/icons.scss'
.pipe sass({
outputStyle: 'expanded'
comments: false
}).on('error', sass.logError)
.pipe gulp.dest 'build/css'
), 250
.pipe gulp.dest 'build/fonts/icons'
\ No newline at end of file
fontelloConfig = 'src/img/icons/fontello.json'
# this eliminates bugs with font generation
gulp.task '_clear_config', ()->
config = JSON.parse(fs.readFileSync(fontelloConfig, 'utf8'))
config.glyphs = []
fs.writeFileSync(fontelloConfig, JSON.stringify(config), 'utf8')
gulp.task '_icons-import-svg', (cb)->
config: fontelloConfig
svgsrc: 'src/img/icons/'
}, cb)
gulp.task '_icons_get', ['_icons-import-svg'], (cb)->
host: ''
config: fontelloConfig
css: 'build/css/icons'
font: 'build/fonts/icons'
scss: true
}, cb)
gulp.task 'icons', ['_clear_config', '_icons_get'], ->
# timeout to wait async disk write operation
setTimeout (->
.pipe(replace('/font/', '/fonts/icons/'))
# recompile styles with new glyphs
gulp.start 'sass'
), 500
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment