sindresorhus / gulp-rev

Static asset revisioning by appending content hash to filenames: `unicorn.css` → `unicorn-d41d8cd98f.css`
MIT License
1.54k stars 218 forks source link

Ability to dump manifest file only #114

Closed beenanner closed 8 years ago

beenanner commented 9 years ago

Is there a way to only dump the manifest file? It would be nice to allow dumping of the manifest file only. A developer would then be able to setup their app to look up the rev version or just fallback to the non-rev version if not found in the manifest for whatever reason. Of course a rewrite rule would be required to support proxying the non-rev versions for the rev version request, but it avoids dumping 2 of each file. Thoughts?

gulp.task('js-rev', function () {
    return gulp.src(['web/js/**/*.js'])
            .pipe(rev())
            .pipe(rev.manifest('js-manifest.json'))
            .pipe(gulp.dest('web'));
});
bobthecow commented 9 years ago

Yeah. It should work just like your example.

beenanner commented 9 years ago

Looks like this guy is the culprit.

...
 var revisionedFile = relPath(firstFileBase, file.path);
 var originalFile = path.join(path.dirname(revisionedFile), path.basename(file.revOrigPath)).replace(/\\/g, '/');

 manifest[originalFile] = revisionedFile;
 cb();
}, function (cb) {
        // no need to write a manifest file if there's nothing to manifest
        if (Object.keys(manifest).length === 0) {
            cb();
            return;
        }
...

The following is returning true since the files are not written to disk.

if (Object.keys(manifest).length === 0) 
torifat commented 8 years ago

Doesn't seem like a major use case to me.

bobthecow commented 8 years ago

It should already do this. If it doesn't, there's a bug.

torifat commented 8 years ago

@bobthecow ok, I will add a test for it then.

torifat commented 8 years ago

@beenanner I just checked and it works. Please use the latest version.

beenanner commented 8 years ago

I'll check it out thanks @bobthecow and @torifat