sindresorhus/gulp-rev — pull request #7 by bobthecow (2014-02-12 19:29:06+00:00)
Title: Add an asset manifest method.

This extends the rev plugin with `rev.manifest()`, for building a map between source and rev'd paths:

```js
var gulp = require('gulp');
var filter = require('gulp-filter');
var rev = require('gulp-rev');

var ASSETS = [
'public/assets/js/*.js',
'public/assets/css/*.css',
'public/assets/fonts/*.*',
'public/assets/img/**/*.*'
];

gulp.task('cachebust', function() {
return gulp.src(ASSETS, {base: 'public'})
.pipe(filter(function(file) {
// Filter out assets that are already rev'd.
return !/-[\da-e]{8}\.[^\.]+$/.test(file.path);
}))
.pipe(rev())
.pipe(gulp.dest('public'))
.pipe(rev.manifest())
.pipe(gulp.dest('public'));
});
```

In keeping with the "options intentionally missing", `rev.manifest()` doesn't allow naming the manifest or choosing a directory, and it doesn't write directly to the filesystem. That can easily be done with `gulp-rename` or other gulp plugins. `rev.manifest()` simply consumes rev'd assets, and emits a new manifest file.

```js
var gulp = require('gulp');
var rev = require('gulp-rev');
var rename = require('gulp-rename');

gulp.task('cachebust', function() {
gulp.src('src/*.css')
.pipe(rev())
.pipe(gulp.dest('dist'))
.pipe(rev.manifest())
.pipe(rename('revmap.json'))
.pipe(gulp.dest(''));
});
```

You could make the case that this could be done in another `gulp-rev-manifest` plugin, but that would require the other plugin to have knowledge that only `gulp-rev` really has access to. If `gulp-rev` were modified to store the `_preRevPath`, as in this patch, then `rev.manifest()` could be isolated into its own plugin. But this somehow seems worse than having a second method on this plugin.

At the very least, I haven't seen any prior art among gulp plugins.

See #2