@crabicode
dev

Как настроить gulp-rev для html?

Я не могу сообразить как заставить gulp заменять ссылки <a href='views/test.html'> в документе?

есть index.html в нём сжимаются js + css и добавляются asset hash, но вот я не понимаю как заставить так же заменять *.html

gulp.task('client:build', ['haml', 'styles', 'coffee'], function () {
  var jsFilter = $.filter('**/*.js');
  var cssFilter = $.filter('**/*.css');

  var assets = $.useref.assets({searchPath: [yeoman.app, '.tmp']});

  return gulp.src(paths.views.main)
    .pipe(assets)
    .pipe(jsFilter)
    .pipe($.ngAnnotate())
    .pipe($.uglify())
    .pipe(jsFilter.restore())
    .pipe(cssFilter)
    .pipe($.minifyCss({cache: true}))
    .pipe(cssFilter.restore())
    .pipe($.rev())
    .pipe(assets.restore())
    .pipe($.revReplace())
    .pipe($.useref())
    .pipe(gulp.dest(yeoman.dist));
});

Исходники
b2da1e7b8a1b46edb8a76ae9c2ffe1bf

Вот, что получаю:
e2f67423af154ff8bef24af1772ee8c1.PNG

CSS имеет хэш, а вот test.hml как будто бы игнорируется
<link rel="stylesheet" href="styles/main-16c86e6036.css">
<a href="views/test.html">Test</a>
  • Вопрос задан
  • 833 просмотра
Решения вопроса 1
@crabicode Автор вопроса
dev
Всё заработало, просто пошагово нужно было всё разбить

gulp.task 'minify-html', ['rev-html', 'assets'], ->
  gulp.src 'dist/**/*.html'
    .pipe minifyHtml
      conditionals: true
      spare: true
      loose: true
      empty: true
    .pipe gulp.dest yeoman.dist

gulp.task 'rev-html', ['assets'], ->
  gulp.src ['.tmp/views/**/*.html']
    .pipe do $.rev
    .pipe gulp.dest 'dist/views'
    .pipe do $.rev.manifest
    .pipe gulp.dest yeoman.dist

gulp.task 'cache-html', ['rev-html'], ->
  gulp.src ['dist/*.html', 'dist/**/*.js', 'dist/**/*.css']
    .pipe $.revReplace manifest: gulp.src('./dist/rev-manifest.json')
    .pipe gulp.dest yeoman.dist

gulp.task 'assets', ['haml', 'coffee', 'bower'], ->
  assets = $.useref.assets(searchPath: [yeoman.tmp])
  global = gulp.src paths.index
    .pipe assets
      .pipe $.if('*.js', do $.ngAnnotate)
      .pipe $.if('*.js', do $.uglify)
      .pipe $.if('*.css', $.minifyCss cache: true)
      .pipe do $.rev
    .pipe do assets.restore
    .pipe do $.useref
    .pipe do $.revReplace
    .pipe gulp.dest yeoman.dist
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы