Last active
April 13, 2019 05:57
-
-
Save dcalhoun/e79ad10d518612d70721 to your computer and use it in GitHub Desktop.
Task for using Grunticon with Gulp thanks to grunticon-lib.
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'), | |
q = require('q'), | |
path = require('path'), | |
fs = require('fs'), | |
Grunticon = require('grunticon-lib'); | |
gulp.task('icons', function () { | |
var deferred = q.defer(), | |
iconDir = 'app/images/icons/', | |
options = { enhanceSVG: true }; | |
var files = fs.readdirSync(iconDir).map(function (fileName) { | |
return path.join(iconDir, fileName); | |
}); | |
var grunticon = new Grunticon(files, 'dist/icons', options); | |
grunticon.process(function () { | |
deferred.resolve(); | |
}); | |
return deferred.promise; | |
}); |
@nsierram grunticon-lib needs the first parameter as an array of files not a glob pattern.
Amending your async code -
var gulp = require('gulp'),
glob = require('glob'),
Grunticon = require('grunticon-lib');
gulp.task('icons', function (done) {
var icons = glob.sync('app/images/icons/*.*'), // <-- get array of files from glob pattern
options = { enhanceSVG: true };
var grunticon = new Grunticon(icons, 'dist/icons', options);
grunticon.process(done);
});
Yup, u are right, I had forgotten to put that line ;)
glob.sync(src)..
Hi! Great code! Is it possibile integrate it with a .pipe so I can use gulp-svgmin before launch grunticon? Can I concatenate the grunticon.loader.js with other JS files and concatenate the .css files with other Css files?
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This slimmer version also works,
it uses gulp async task support
and glob.