gulp-rev-all doing replace no id dom-module

0

I'm trying to version the assets from my polymer web app using gulp-rev-all. However, gulp-rev-all is doing replace 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 found a possible solution to how this should be corrected, but I honestly could not figure out how to correct my case. (can be viewed here link )

    
asked by anonymous 31.08.2017 / 22:33

1 answer

0

I have seen a solution with replace as well and I found it to be bad because of these conflicts it can give. I solved this using the gulp-hash so that it places the hash in the file name and generates a json with the generated hash. / p>

Gulp example:

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 main.css file by unifying all my CSSs.

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

The third ensures that each will be called in asynchronous sequence.

Then with json I get the filename to put in <head> of the site without having to replace.

    
10.03.2018 / 04:47