shonny-ua / gulp-rev-collector

Static asset revision data collector from manifests, with was generated from different streams and replace they's links in html template.
MIT License
150 stars 41 forks source link

It seems that collector doesn't work #20

Closed YDSS closed 8 years ago

YDSS commented 8 years ago

HI, I'm using gulp-rev-collector and found it not working. I write a demo to reappear what I meat. Here is my gulpfile.js:

'use strict'

let gulp = require('gulp');
let rev = require('gulp-rev');
let revController = require('gulp-rev-collector');
let minifyHTML = require('gulp-minify-html');
let DIST = './dist';

gulp.task('default', ['css', 'js', 'index']);

gulp.task('css', () => {
    gulp.src('./src/**.css')
        .pipe(rev())
        .pipe(gulp.dest(DIST))
        .pipe(rev.manifest('css-map.json', {
            merge: true
        }))
        .pipe(gulp.dest(DIST));
});

gulp.task('js', () => {
    gulp.src('./src/**.js')
        .pipe(rev())
        .pipe(gulp.dest(DIST))
        .pipe(rev.manifest('js-map.json', {
            merge: true
        }))
        .pipe(gulp.dest(DIST));
});

gulp.task('index', () => {
    gulp.src([DIST + '/**.json', './src/index.html'])
        .pipe(revController())
        .pipe(minifyHTML({
            empty: true,
            spare: true
        }))
        .pipe(gulp.dest(DIST));
});

I found if I directly run gulp, link and script tag in index.html did not be replaced by url with md5, but if I run gulp index, it works. So I guess, maybe when collector runs the manifest file generate by gulp-rev has not created.

YDSS commented 8 years ago

I found where I am wrong: I didn't return in every task which task index depends, I'm sorry~~