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

后端 未结 2 1760
栀梦
栀梦 2021-01-25 09:17

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 see

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-25 09:30

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

提交回复
热议问题