Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lytedev's avatar

Elixir rev-manifest Windows Issues

Windows 8.1 here,

So I'm having trouble with elixir outputting backslashes in my versioned/built asset paths beca use of what I assume to be Node's path builder to concatenate directories using the native directory separator. So I'm wanting to have a simple gulp task that replaces the \ (or \\) in the public/build/rev-manifest.json with forward slashes - seems like the best way to solve this problem to me? Maybe I'm doing something dumb, which is entirely possible as I'm brand new to gulp and task runners in general.

Anyways, I'd love some assistance or guidance on this. I'm currently extending elixir with a simple fixRevManifest function that uses gulp-replace for replacing as specified above. The problem seems to be with some kind of concurrency issue as sometimes it works when outputting to a different file and never works when outputting/overwriting the original rev-manifest.json file.

var gulp = require('gulp');
var elixir = require('laravel-elixir');
var replace = require('gulp-replace');

elixir.extend('fixRevManifest', function(src, output) {

    gulp.task('fix-rev-manifest', function() {
        return gulp.src('./public/build/rev-manifest.json')
            .pipe(replace(/\\\\/g, '/'))
            .pipe(gulp.dest("./public/build/actual"));
    });

    this.registerWatcher('fix-rev-manifest');

    return this.queueTask('fix-rev-manifest');

});

elixir(function(mix) {
    mix
        .sass("main.scss")
        .styles(["css/main.css"])
        .routes()
        .events()
        .version("css/all.min.css")
        .fixRevManifest()
        ;
});

Appreciate any and all help. Thanks!

0 likes
10 replies
Marwelln's avatar

Update your node packages with npm update. A fix for this have been commited and is available in v2.0.0 of gulp-rev. Elixirs package.json have been updated to include this fix.

2 likes
lytedev's avatar

To others: edit your Laravel package.json to use laravel-elixir 0.4.4 and npm update as previously mentioned.

Definitely fixed the issue with using backslashes, however, my rev-manifest.json file now uses absolute paths, making elixir('all.min.css') not work properly.

Here's my new rev-manifest.json file:

{
  "C:/Users/Public/Applications/xampp/htdocs/lytedev/public/build/css/all.min.css": "C:/Users/Public/Applications/xampp/htdocs/lytedev/public/build/css/all.min-9d26224a.css"
}

Do I need to include a flag in my .version() gulp call that provides some kind of relative directory? I'll skim over gulp-rev's documentation.

Thanks for your help!

EDIT: My current Gulpfile.js

var elixir = require('laravel-elixir');

elixir(function(mix) {
    mix
        .sass("main.scss")
        .styles(["css/main.css"])
        .version("css/all.min.css")
        .routes()
        .events();
});
JeffreyWay's avatar

Hmm - I wonder if that, again, is a Windows thing. I just tried it out with a fresh installation, and the paths are local, as they should be.

{
  "css/one.css": "css/one-cdc469e2.css",
  "js/script.js": "js/script-a9a97914.js"
}
Marwelln's avatar

@lytedev, sindresorhus made modifications to my commit making it return a full path instead of a relative.

Go into node_modules/gulp-rev aand open up index.js and change the relPath function to this:

function relPath(base, filePath) {
     if (filePath.indexOf(base) !== 0) {
        return filePath.replace(/\\/g, '/');
    }
    var newPath = filePath.substr(base.length).replace(/\\/g, '/');
    if (newPath[0] === '/') {
        return newPath.substr(1);
    } else {
        return newPath;
    }
}
vjacob's avatar

I am not using elixir but this is how i solved the absolute path problem in windows. I am using gulp-slash and it'll change the paths so i get relative paths from gulp-rev


var gulp = require('gulp'); var rev = require('gulp-rev'); var slash = require('gulp-slash'); var build_path = './public/assets/build'; var paths = { styles_build : build_path + '/styles/', script_build : build_path + '/script/', }; // Version css and javascript for cache-busting gulp.task('versioning', ['less', 'browserify'], function() { return gulp.src( [ paths.styles_build + '/main.min.css', paths.script_build + '/main.min.js' ], {base: build_path}) .pipe(gulp.dest(build_path)).pipe(slash()) .pipe(rev()) .pipe(gulp.dest(build_path)).pipe(slash()) .pipe(rev.manifest()) .pipe(gulp.dest(build_path)); });
vjacob's avatar

maybe gulp-slash can be added to elixir so relative paths can be returned in rev-manifest for windows users?

vjacob's avatar

never mind, as of gulp-rev 2.0.1 just released, you no longer need gulp-slash, relative paths should be returned on windows after the update

lytedev's avatar

Fantastic! I'll give this a whirl soon as I can.

lytedev's avatar

Works. Fantastic. Hugs and kisses all around.

Please or to participate in this conversation.