jonkemp / gulp-useref

Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.
MIT License
705 stars 93 forks source link

revisioning assets with v3 api #164

Closed zellwk closed 8 years ago

zellwk commented 8 years ago

Hello, how do I do this with v3 api? I'm specifically looking for the rev() and revReplace() part.

gulp.task('useref', function() {
  var assets = $.useref.assets();

  return gulp.src(config.useref.src)
    .pipe(assets)
    .pipe($.if('*.js', $.uglify()))
    .pipe($.if('*.css', $.uncss(config.uncss.options)))
    .pipe($.if('*.css', $.minifyCss()))
    .pipe($.rev())
    .pipe(assets.restore())
    .pipe($.useref())
    .pipe($.revReplace())
    .pipe(gulp.dest(config.useref.dest));
});
jonkemp commented 8 years ago

Use gulp-if before gulp-rev just like you are doing for the minification and gulp-rev-replace should work as is.

zellwk commented 8 years ago

What do we test for gulp-if? *.html, *.css or *.js?

jonkemp commented 8 years ago

CSS and JS files.

zellwk commented 8 years ago

Cool. Got it to work. Thanks.

jonkemp commented 8 years ago

:metal: