gulp-rev icon indicating copy to clipboard operation
gulp-rev copied to clipboard

Wrong directory in manifest

Open thany opened this issue 8 years ago • 7 comments

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.

thany avatar Oct 24 '16 16:10 thany

What is the structure of source/sass?

I think you need to (1) include {base: 'source'} within gulp.srcas 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.

lukeed avatar Oct 24 '16 16:10 lukeed

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.

f15u avatar Dec 14 '16 20:12 f15u

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 avatar Jan 11 '17 11:01 Dayjo

@Dayjo same problem here, did you find a solution?

robinparisi avatar Oct 18 '17 15:10 robinparisi

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"
}

reflexator avatar Dec 22 '17 22:12 reflexator

After like 4 hours of searching I finally find fix, how to fix it

Tell me about it, your solution worked for me also.

lmj0011 avatar Jul 05 '18 23:07 lmj0011

.pipe(rename({ dirname: "dist/css" // rename dir in manifest }))

Thank you very much, worked for me

mohammad-anas avatar Oct 14 '18 13:10 mohammad-anas