Last active
June 23, 2016 17:11
-
-
Save dmmarmol/c04d446685c375377ce7feeccd2b0b34 to your computer and use it in GitHub Desktop.
Gulpfile made for creating your custom icon fonts from .svg files.
This file contains hidden or 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
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