Skip to content

Instantly share code, notes, and snippets.

@prosenjit-manna
Created August 25, 2017 07:09
Show Gist options
  • Save prosenjit-manna/89d289a797a622667e77eeb0d8259ff8 to your computer and use it in GitHub Desktop.
Save prosenjit-manna/89d289a797a622667e77eeb0d8259ff8 to your computer and use it in GitHub Desktop.
icon-gulp
'use strict';
var gulp = require('gulp');
var iconfont = require('gulp-iconfont');
var iconfontCss = require('gulp-iconfont-css');
var fontName = 'Icons';
gulp.task('iconfont_styles', function(){
gulp.src(['src/assets/images/icons/*.svg'])
.pipe(iconfontCss({
fontName: fontName,
path: 'src/assets/images/icons/_icons.scss',
targetPath: '../../styles/_icons.scss',
}))
.pipe(iconfont({
fontName: fontName,
normalize:true,
formats: ['ttf', 'woff', 'svg'],
}))
.pipe(gulp.dest('src/assets/fonts/'));
});
gulp.task('iconfont_variable', function(){
gulp.src(['src/assets/images/icons/*.svg'])
.pipe(iconfontCss({
fontName: fontName,
path: 'src/assets/images/icons/_icons-variables.scss',
targetPath: '../../styles/_icons-variables.scss',
}))
.pipe(iconfont({
fontName: fontName,
normalize:true,
formats: ['ttf', 'woff', 'svg'],
}))
.pipe(gulp.dest('src/assets/fonts/'));
});
gulp.task('icon_preview', function(){
gulp.src(['src/assets/images/icons/*.svg'])
.pipe(iconfontCss({
fontName: fontName,
path: 'src/assets/images/icons/_icon-preview.html',
targetPath: '../../../temp/icon-preview.html',
}))
.pipe(iconfont({
fontName: fontName,
normalize:true,
formats: ['ttf', 'woff', 'svg'],
}))
.pipe(gulp.dest('src/assets/fonts/'));
});
gulp.task('icon', ['iconfont_variable', 'iconfont_styles', 'icon_preview']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment