Closed codekirei closed 9 years ago
Try it with the es.merge
version and see if that's any better?
So the es.merge
version runs without error but doesn't preserve old values in rev-manifest.json
. I put an existing manifest with data from another project in build/assets
, and it gets completely overwritten. If I'm understanding correctly, I would have expected the new key:value
pairs to get appended to the bottom of the existing manifest because the keys are different.
Thus, unless I'm screwing something up on my end, while the code runs, I think it defeats the purpose of the PR?
@c0, you said you have this working in an app. Are you succesfully adding new data to rev-manifest.json
(or whatever you're renaming it to) from separate tasks without overwriting? If so, would you mind sharing some examples of what your gulp.task
s look like?
Code I used:
var gulp = require('gulp');
var rev = require('gulp-rev');
var es = require('event-stream');
gulp.task('default', function(){
var assets = gulp.src(['assets/css/*.css', 'assets/js/*.js'], {base: 'assets'})
.pipe(gulp.dest('build/assets'))
.pipe(rev())
.pipe(gulp.dest('build/assets'));
var manifest = gulp.src('build/assets/rev-manifest.json', {base: 'assets'});
return es.merge(assets, manifest)
.pipe(rev.manifest())
.pipe(gulp.dest('build/assets'));
});
Try changing the base
on your rev-manifest
src call to be build/assets
?
Still overwriting rev-manifest.json
.
Same es.merge
code as above, except changed this line:
var manifest = gulp.src('build/assets/rev-manifest.json', {base: 'assets'});
to this, as instructed:
var manifest = gulp.src('build/assets/rev-manifest.json', {base: 'build/assets'});
Quick update: just to be sure I'm not crazy, I split the example from the readme into two separate tasks (css/js). Both take rev-manifest.json
as source with gulp-filter
, but both overwrite the manifest on each run.
Code for the curious:
var gulp = require('gulp');
var rev = require('gulp-rev');
var gulpFilter = require('gulp-filter');
var jsFilter = gulpFilter(['**/*.js']);
var cssFilter = gulpFilter(['**/*.css']);
var src = [
'assets/css/**/*.css',
'assets/js/**/*.js',
'build/assets/rev-manifest.json'
];
function taskBase(filterType){
return gulp.src(src, {base: 'assets'})
.pipe(filterType)
.pipe(gulp.dest('build/assets'))
.pipe(rev())
.pipe(gulp.dest('build/assets'))
.pipe(filterType.restore())
.pipe(rev.manifest())
.pipe(gulp.dest('build/assets'));
}
gulp.task('css', function(){
taskBase(cssFilter);
});
gulp.task('js', function(){
taskBase(jsFilter);
});
gulp.task('default', function(){
return gulp.start(
'js',
'css'
);
});
D'oh. I see what happened. I submitted a PR to fix it: https://github.com/sindresorhus/gulp-rev/pull/59
Please comment there to see if it works for you.
Backstory: I unintentionally found a different way to create a manifest.json
that appeared to be appending in my app:
public/assets
public/assets
, filters out fingerprinted names, and writes to the manfest.json
.So each time it took whatever was in the build dir and created a manifest, rather than using what came down the gulp pipe.
the looker/gulp-rev
fix works me. Any reason not to merge it?
Hi all, I'm having trouble successfully replicating the functionality added with #51.
If I follow the example in the readme exactly:
I get this error:
Maybe it has to do with the
gulp.src
call mid-stream?If it helps, I have
style.css
inassets/css/
andscripts.js
inassets/js
, and if I look inbuild/assets
after the error,css/
hasstyle.css
andstyle-hash.css
, whilejs/
only hasscripts.js
. This would seem to indicate the error is somewhere between rev'ing those assets, but when I remove the code specific to generatingrev-manifest.json
both types of assets are rev'd properly.