Skip to content

Instantly share code, notes, and snippets.

@dmmarmol
Last active June 23, 2016 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmmarmol/c04d446685c375377ce7feeccd2b0b34 to your computer and use it in GitHub Desktop.
Save dmmarmol/c04d446685c375377ce7feeccd2b0b34 to your computer and use it in GitHub Desktop.
Gulpfile made for creating your custom icon fonts from .svg files.
var gulp = require('gulp');
var iconfont = require('gulp-iconfont');
var iconfontCss = require('gulp-iconfont-css');
var ICONFONT = 'font-file-name';
// Working Dir
var APP = {
FOLDER: APPFOLDER,
ICONS: APPFOLDER+'/src/icons',
FONTS: APPFOLDER+'/src/fonts'
}
// SASS Dir
var SASS = {
FOLDER: APPFOLDER+'/src/scss',
FILES: [APPFOLDER+'/src/scss/**/*.scss', '!'+APPFOLDER+'/src/scss/vendor/**/*.scss'],
FONTS: APPFOLDER+'/src/scss/fonts'
}
// Icon fonts
// @see https://github.com/nfroidure/gulp-iconfont
// @see https://github.com/backflip/gulp-iconfont-css
var runTimestamp = Math.round(Date.now()/1000);
gulp.task('iconfont', function(){
return gulp.src( [APP.ICONS + '/*.svg'] )
.pipe(iconfontCss({
fontName: ICONFONT,
path: SASS.FONTS+'/_template.scss',
targetPath: '../../../'+SASS.FONTS+'/_'+ICONFONT+'.scss',
fontPath: APP.FONTS
}))
.pipe(iconfont({
fontName: ICONFONT, // required
prependUnicode: true, // recommended option
formats: ['ttf', 'eot', 'woff', 'svg'], // default, 'woff2' and 'svg' are available
timestamp: runTimestamp, // recommended to get consistent builds when watching files
normalize: true, // Normalize the svg canvas size between files
fontHeight: 1001
})).on('glyphs', function(glyphs, options) {
console.log(glyphs.name +' - '+ glyphs.unicode);
})
.pipe(gulp.dest( APP.FONTS ));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment