gulp-rev-append
gulp-rev-append copied to clipboard
Does not work at all
Version 0.1.6
I have in client/index.html:
<script src="lib/js/vendor.min.js?rev="></script>
In Gulp:
gulp.task('rev', function() { gulp.src('client/index.html') .pipe(rev()) .pipe(gulp.dest('./dist')); });
In my html and after running gulp, output file is same.
@mparisi76 please try:
<script src="lib/js/vendor.min.js?rev=@@hash"></script>
And let me know the results.
I can see in the documentation where it may be confusing:
"The only requirement is that the dependency to be appended with the hash be declared using `?rev=`. The `@@hash` is not required, and any value will be overriden as the dependency file contents change."
In fact, i believe it needs at least one character - any character or string - in order to perform the regex matching:
"... using the following regex: (?:href|src)="(.*)[\?]rev=(.*)[\"]"
no, this doesn't seem to work at all...
+1
+1
+1
+1
+1
hrm :/
Getting a lot of +1's on this. Quick question so I can help to resolve:
Is it a +1 on this example not working:
<script src="lib/js/vendor.min.js?rev="></script>
or this example not working (which is supported and tested)?
<script src="lib/js/vendor.min.js?rev=@@hash"></script>
I may need more steps to reproduce what seems to be the problem for you all. I just installed 0.1.7 and did a basic test against the latter example and it worked as expected. As well, all the test pass.
Please let me know, so I can assist further.
<script src="js.js?rev=@@hash"></script>
<link rel="stylesheet" href="common.css?rev=@@hash">
<link rel="stylesheet" href="ll.css?rev=@@hash">
after build ↓↓↓↓↓
It worked for me, but only on a gulp.watch
. If I do it from a gulp.task()
directly, it doesn't work. I believe this is happening because the files aren't available for hashing when the revision appender runs on build. So I need to use runSequential
to run the HTML part after all the assets have been created.
Hi @Sawtaytoes , can you put an example please with gulp.watch, for me not work too.
The issue most people are probably having is that Gulp runs tasks concurrently. This is great in normal operation, but if you're copying files around and generating the public folder, your index.html file might not exist when you run gulpRevAppend
. Doing them in sequence like this where buildIndex
occurs after build
will get it working.
You'll need to do something like this where you utilize runSequence
to get your tasks running in a certain order:
ES2015+
const gulp = require('gulp')
const runSequence = require('run-sequence')
gulp.task(
'deploy',
callback => runSequence('clean', 'build', 'buildIndex', callback)
)
ES5
'use strict';
var gulp = require('gulp');
var runSequence = require('run-sequence');
gulp.task('deploy', function (callback) {
return runSequence('clean', 'build', 'buildIndex', callback);
});