2

I'm having issues trying to run gulp-rev-all correctly in html files within subfolders. My current site structure is kind of this:

/index.html
/gulpfile.js
/appsubFolder
    |-> index.html
/Content
    |-> some.css
    |-> someOther.css
/Scripts
    |-> some.js
    |-> someOther.js

The file /appsubFolder/index.html has the build tags declared like this:

<!-- build:css ../Content/styles.min.css -->
<link href="../Content/some.css" rel="stylesheet">
<link href="../Content/someOther.css" rel="stylesheet">
<!-- endbuild -->

And then in the gulpfile, I have the task configured like this:

gulp.task('minifyBundleRevision', ['clean:bundles', 'publish'], function () {
    var revAll = new $.revAll({ dontRenameFile: ['.html'], debug: true });
    return gulp.src('appsubFolder/index.html')
        .pipe($.useref())
        .pipe($.if("*.js", $.uglify()))
        .pipe($.if("*.css", $.uglifycss()))
        .pipe(revAll.revision())
        .pipe(gulp.dest(publishFolder + '/appsubFolder'));
});

Problem is, everything runs fine, but the file appsubFolder/index.html ends up with the section like this:

<link href="../Content/styles.min.css" rel="stylesheet">

instead of

<link href="../Content/styles.min.[hash-here].css" rel="stylesheet">

despite of the fact that in folders Content and Scripts, the files appear there with the hashes on their names. So the problem is that even when the revision function runs well on files, it's not replacing correctly the html in the file /appsubFolder/index.html Worth to note is everything runs well on /index.html.

How should I fix this?

CesarD
  • 573
  • 14
  • 30
  • Any solution to this? – jward01 Mar 07 '17 at 19:33
  • 1
    I ended up replacing the implementation of $.revAll() with $.rev(). I guess the developer released a new version that might have fixed this, but I haven't tried it again. With $.rev() it's working fine so far. – CesarD Mar 08 '17 at 13:54
  • Thats a great approach. I will try that too. I also was not about to get $.revAll() to work, my band-aid approach involved using gulp-inject and running that after $.revAll() was run, so that gulp-inject could populate the index.html with the new js/css file names – jward01 Mar 08 '17 at 16:46

0 Answers0