Skip to content Skip to sidebar Skip to footer

Can't Get Gulp-rev-replace Working With Gulp-useref

Continuing my previous question - but this time is the next step: getting file revisions to work. I'm working through johnpapa's course on automation with Gulp and seem to hit anot

Solution 1:

You have to add replaceInExtensions: '.jsp' to your options for revReplace().

I had this problem for a day and a half before I looked at the plugin code and figured it out. I'm using .php files. The documentation does say you need to do this but it's easily missed.

Hope it helps.

Solution 2:

In the meantime (unless I find the source of the problem or any of you can help), I've chosen a different cache busting scheme:

gulp.task('build-dev', ['inject'], function () {

    var assets = $.useref.assets({searchPath: ''});
    var cb = Math.random();

    return gulp
        .src(config.indexFile)
        .pipe($.rename('test.jsp'))
        .pipe($.plumber())
        .pipe(assets)
        .pipe(assets.restore())
        .pipe($.useref())
        .pipe($.replace('dist/css/lib.css', 'dist/css/lib.css?cb=' + cb))
        .pipe($.replace('dist/css/app.css', 'dist/css/app.css?cb=' + cb))
        .pipe($.replace('dist/js/lib.js', 'dist/js/lib.css?cb=' + cb))
        .pipe($.replace('dist/js/app.js', 'dist/js/app.js?cb=' + cb))
        .pipe(gulp.dest(config.indexLocation))
        ;
});

It's not the answer I want, but it is an answer I need. :)

Post a Comment for "Can't Get Gulp-rev-replace Working With Gulp-useref"