gulp-rev
gulp-rev copied to clipboard
Wrong directory in manifest
Please consider this task:
gulp.task("sass-build", function() {
return gulp.src(["source/sass/**/*.scss"])
.pipe(compass({
sass: "source/sass",
}))
.pipe(rev())
.pipe(gulp.dest("build/css"))
.pipe(rev.manifest())
.pipe(gulp.dest("build/"));
});
In summary:
Source root folder is source/
Build root folder is build/
SCSS gets compiled from source/scss
into build/css
The result is a rev-manifest file in build/
containing:
{
"style.css": "style-01e630406e.css"
}
This is wrong. I would expect it to be:
{
"css/style.css": "css/style-01e630406e.css"
}
After all, the manifest is written one level higher, so it should understand that it needs to add the missing part of the path. As a result, gulp-rev-replace doesn't replace the reference to style.css in the html.
Why not save the manifest in the build/css
folder? Well, somehow that also doesn't work well with gulp-rev-replace. But that's really beside the point. The point is that gulp-rev is generating a manifest that won't work.
What is the structure of source/sass
?
I think you need to (1) include {base: 'source'}
within gulp.src
as seen here or (2) split this into two streams so that the first writes into build/css
and then the second sources the same directory. (This "second stream" would look nearly identical to the linked example.
I have the same issue, even with {base: 'source'}
.
This is my task:
gulp.task('sass', function () {
return gulp.src('scss/*.{sass,scss}', {cwd: './src', base: './src'})
.pipe(sass({
includePaths: [
'./bower_components'
],
precision: 2,
sourceMap: true,
sourceMapEmbed: true,
outputStyle: 'compact'
}).on('error', sass.logError))
.pipe(rev())
.pipe(gulp.dest('./public/css'))
.pipe(rev.manifest({
base: './',
merge: true
}))
.pipe(gulp.dest('./'));
});
This is the rev-manifest.json
content:
{
"scss/bootstrap.css": "scss/bootstrap-55a07f3bb1.css"
}
Changing the base
option with base: './src/sass'
the result is:
{
"/vagrant/public/scss/bootstrap.css": "/vagrant/public/scss/bootstrap-55a07f3bb1.css"
}
Is there any option to follow the destination path (gulp.dest()
) after rev()
or changing the base folder?
I don't want to install other plugins it in order to fix this behaviour.
Also having a similar issue where we have multiple stand alone js files for different areas, for instance;
/dashboards/something/some-feature.js
/admin/something-else/admin-feature.js
And they're all just getting written in the manifest to something/file.js
rather than the full path, which makes aliasing it impossible. I can't seem to find a nice way of making it keep the path i.e. the manifest looking like;
{
"/dashboards/something/some-feature.js": "/dashboards/something/some-feature-89s8ad7f0ss7d.js"
}
instead of what I get now (missing off dashboards from the path);
{
"something/some-feature.js": "some-feature-89s8ad7f0ss7d.js"
}
If anyone has any work arounds for this atm that'd be really useful
@Dayjo same problem here, did you find a solution?
After like 4 hours of searching I finally find fix, how to fix it
Before
gulp.task('sass', function() {
return gulp.src(["www/css/web.scss"])
.pipe(concat('web.css'))
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rev())
.pipe(gulp.dest("www/dist/css"))
.pipe(rev.manifest({
merge: true
}))
.pipe(gulp.dest("www/dist/css"))
.pipe(browserSync.stream());
});
results in
{
"web.css": "web-b70dd90d41.css"
}
now
gulp.task('sass', function() {
return gulp.src(["www/css/web.scss"])
.pipe(concat('web.css'))
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rev())
.pipe(gulp.dest("www/dist/css"))
.pipe(rename({
dirname: "dist/css" // rename dir in manifest
}))
.pipe(rev.manifest({
merge: true
}))
.pipe(gulp.dest("www/dist/css"))
.pipe(browserSync.stream());
});
outputs
{
"dist/css/web.css": "dist/css/web-b70dd90d41.css"
}
After like 4 hours of searching I finally find fix, how to fix it
Tell me about it, your solution worked for me also.
.pipe(rename({ dirname: "dist/css" // rename dir in manifest }))
Thank you very much, worked for me