Search code examples
gulpgulp-useref

useref.assets break gulp pipeline


when I try to use gulp-useref on my index.html file, pipeline breaks and the task won't finish what is wrong with it? I have testet useref on my html source and it was fine

gulp.task('html', function () {
  var htmlFilter = $.filter(['*.html', '**/*.html']);
  var cssFilter = $.filter('**/*.css');
  var assets;

  return gulp.src(
    path.join(conf.paths.src, '*.html')
  )
  .pipe($.debug({title: 'after src:'}))
  .pipe(assets = $.useref.assets())
  .pipe($.debug({title: 'after useref.assets():'}))
  .pipe($.rev())
  .pipe(cssFilter)
  .pipe($.minifyCss())
  .pipe(cssFilter.restore())
  .pipe(assets.restore())
  .pipe($.useref())
  .pipe($.revReplace())
  .pipe(htmlFilter) 
  .pipe($.minifyHtml({
    empty: true,
    spare: true,
    quotes: true,
    conditionals: true
  }))
  .pipe(htmlFilter.restore())
  .pipe(gulp.dest(path.join(conf.paths.dist, '/')))
  .pipe($.size({ title: path.join(conf.paths.dist, '/'), showFiles: true }));
});

debug won't show after useref.assets


Solution

  • From the gulp-useref github page:

    Changes under the hood have made the code more efficient and simplified the API. Since the API has changed, please observe the usage examples below.

    Assets is no longer available so I think that's your problem.