Gulp-rev-all replacing the dom-module id

Asked

Viewed 74 times

0

I am trying to versioning the Assets from my Polymer web app using Gulp-rev-all. However, Gulp-rev-all is replacing and adding hash also in the dom-module id.

Ex: <dom-module id="cr-header.fd743a17">

gulp.task('version-assets', ['vulcanize'], function () {
    if (production) {

        gulp
            .src(
            [
                folder.build + 'app/src/**/**/*.html',
                folder.build + 'app/src/**/*.js',
                folder.build + 'app/src/**/*.css',
                folder.build + 'app/index.html',
                folder.build + 'app/error-404.html',
            ])
            .pipe(RevAll.revision({ dontRenameFile: [/^\/favicon.ico$/g, /^\/index.html/g, /^\/error-404.html/g] }))
            .pipe(revdel())
            .pipe(gulp.dest(folder.build + 'app/'))
            .pipe(RevAll.manifestFile())
            .pipe(gulp.dest(folder.build + 'app/src'));
    }
});

I have found a possible solution to how this should be corrected, but I honestly could not understand how to correct my case. (can be seen here https://github.com/smysnk/gulp-rev-all/issues/97)

1 answer

1

I saw a solution with replace as well and I found it bad exactly because of these conflicts it can give. I solved this using the Gulp-hash so that he puts the hash in the file name and generates a json with the generated hash.

Example of Gulp:

gulp.task('css-default', function() {
    return gulp.src([
      './static/css/*.css'
    ])
        .pipe(cssmin())
        .pipe(concat('main.css'))
        .pipe(gulp.dest('./static/assets/css'))
});

gulp.task('css-hash', function() {
    return gulp.src(['./static/assets/css/main.css'])
        .pipe(hash()) 
        .pipe(gulp.dest('./static/assets/css')) 
        .pipe(hash.manifest('assets.json', { 
          deleteOld: true,
          sourceDir: './static/assets/css'
        }))
        .pipe(gulp.dest('.')); 
});

gulp.task('css', ['css-default'], function(){
    gulp.start('css-hash');
});

The first gulp.task generates the file main.css unifying all my Csss.

The second generates the hashed file and a json that will have hash information.

The third ensures that each of them will be called in sequence and.

Ai with json I take the name of the file to put in <head> of the site without needing to replace.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.