jamesknelson / gulp-rev-replace

Rewrite occurences of filenames which have been renamed by gulp-rev
MIT License
389 stars 62 forks source link

Index replacements fail to occur when using gulp-filter #59

Closed dietrich-stein closed 8 years ago

dietrich-stein commented 8 years ago

The task shown below fails to replace the not-yet-revved references in my index.html file. Other than that is is working perfectly. I have tried so many different approaches at this point that I'm considering abandoning this package. The only way I can get it to work is to remove my filters and allow it to write all of CSS and JS files to the root path where the index.html file resides. Any ideas?

gulp.task('assets-revision', ['analyze', 'clean', 'assets-fonts', 'assets-other'], function() {
    var jsFilter = plugins.filter('**/*.js', { restore: true });
    var cssFilter = plugins.filter('**/*.css', { restore: true });

    return gulp.src([
        config.build + '/index.html',
        config.build + '/css/**/*.css',
        config.build + '/js/**/*.js'
    ])

    .pipe(plugins.rev())

    .pipe(jsFilter)
    .pipe(gulp.dest(config.build + '/css/'))
    .pipe(jsFilter.restore)

    .pipe(cssFilter)
    .pipe(gulp.dest(config.build + '/js/'))
    .pipe(cssFilter.restore)

    .pipe(plugins.revReplace());
});
dietrich-stein commented 8 years ago

For anyone searching the closed list my solution was to jump ship over to these:

smysnk/gulp-rev-all nib-health-funds/gulp-rev-delete-original

That allowed me simplify things considerably:

gulp.task('assets-revision', ['analyze', 'clean', 'assets-fonts', 'assets-other'], function() {
    var revAll = new plugins.revAll({
        dontRenameFile: [
            /^\/index.html/g
        ]
    });

    return gulp.src([
        config.dest + '/**/index.html',
        config.dest + '/css/**/*.css',
        config.dest + '/js/**/*.js'
    ])
        .pipe(revAll.revision())
        .pipe(revdel())
        .pipe(gulp.dest(config.dest + '/'));
});