Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong directory in manifest #200

Open
thany opened this issue Oct 24, 2016 · 7 comments
Open

Wrong directory in manifest #200

thany opened this issue Oct 24, 2016 · 7 comments

Comments

@thany
Copy link

thany commented Oct 24, 2016

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.

@lukeed
Copy link

lukeed commented Oct 24, 2016

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.

@FedericoBiccheddu
Copy link

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.

@Dayjo
Copy link

Dayjo commented Jan 11, 2017

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

@robinparisi
Copy link

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

@reflexator
Copy link

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

@lmj0011
Copy link

lmj0011 commented Jul 5, 2018

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

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

@mohammad-anas
Copy link

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

Thank you very much, worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants