|
var gulp = require('gulp'); |
|
var consolidate = require('gulp-consolidate'); |
|
var iconfont = require('gulp-iconfont'); |
|
var rename = require("gulp-rename"); |
|
|
|
var async = require('async'); |
|
|
|
var runTimestamp = Math.round(Date.now()/1000); |
|
|
|
|
|
gulp.task('iconfont', function(done){ |
|
var iconStream = gulp.src(['icons/*.svg']) |
|
.pipe(iconfont({ |
|
fontName: 'myfont', // required |
|
// prependUnicode: true, // recommended option |
|
normalize:true, // recommended option |
|
fontHeight: 1001, // recommended option |
|
timestamp: runTimestamp, // recommended to get consistent builds when watching files |
|
formats: ['ttf', 'eot', 'woff','svg'] |
|
})); |
|
|
|
async.parallel([ |
|
function handleGlyphs (cb) { |
|
iconStream.on('glyphs', function(glyphs, options) { |
|
gulp.src('font-template.scss') |
|
.pipe(consolidate('lodash', { |
|
glyphs: glyphs, |
|
fontName: 'myfont', // name that font will get, used as file name and font face name |
|
fontPath: '../fonts/', // string used in font-template.scss to generate the right path |
|
className: 'ico' // prefix for font used in font-template.scss |
|
})) |
|
.pipe(rename('icons-compiled.scss')) // rename file in a convinient way |
|
.pipe(gulp.dest('scss/')) // move file in a specific folder |
|
.on('finish', cb); |
|
}); |
|
}, |
|
function handleFonts (cb) { |
|
iconStream |
|
.pipe(gulp.dest('fonts/')) // folder where store the font files (ttf, eot, woff, svg) |
|
.on('finish', cb); |
|
} |
|
], done); |
|
}); |