nfroidure/gulp-iconfont

Not clear when task completes

Closed this issue · 3 comments

Hi,

Gulp states that the iconfont task has finished, but gulp-svgicons2svgfont actually completes later.

This is my configuration:

// Generate iconfont
gulp.task('iconfont', function () {
  gulp.src(['app/images/icons/*.svg'])
    .pipe(gulp.iconfont({
      fontName: 'myfont',
      normalize: true
    }))
    .on('glyphs', function (glyphs, options) {
      gulp.src('config/iconfont-template.css')
        .pipe(gulp.consolidate('lodash', {
          glyphs: glyphs,
          fontName: 'myfont',
          fontPath: '/fonts/iconfont/',
          className: 'icon'
        }))
        .pipe(gulp.rename('iconfont.css'))
        .pipe(gulp.dest('app/styles/'));
    })
    .pipe(gulp.dest('app/fonts/iconfont/'));
});

This is what I get when I run Gulp:

$ gulp
[11:43:44] Using gulpfile ~/temp/gulpfile.js
[11:43:44] Starting 'default'...
[11:43:44] Starting 'iconfont'...
[11:43:44] Finished 'iconfont' after 256 ms
[11:43:44] Starting 'css'...
[11:43:45] Finished 'css' after 578 ms
[11:43:45] Starting 'browser'...
[11:43:45] Finished 'browser' after 37 ms
[11:43:45] Finished 'default' after 874 ms
[BS] Access URLs:
 ---------------------------------------
       Local: http://localhost:3000
    External: http://172.163.206.122:3000
 ---------------------------------------
          UI: http://localhost:3001
 UI External: http://172.163.206.122:3001
 ---------------------------------------
[BS] Serving files from: app
[11:43:45] gulp-svgicons2svgfont: Font created

As you can see gulp-svgicons2svgfont actually completes way after the iconfont task is supposed to be finished. Any idea how to fix this?

Thanks!

I think you're missing a return statement. Your task needs to either accept a callback our return a gulp stream. Otherwise it is assumed to only do synchronous work. Just put return before gulp.src.

Makes sense. I actually took this example from the docs: @nfroidure do you think we should update them? If you like I can do a PR for that.

You're welcome!