Can't get gulp-rev-replace working with gulp-useref

孤街醉人 提交于 2019-12-02 05:57:36

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.

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. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!