So I've used gulp-usemin for a while and generally like it. In particular, I love the built in cache-busting ability
Before
<!-- build:js js/app.js -->
<script type="text/javascript" src="js/script1.js"></script>
<script type="text/javascript" src="js/script2.js"></script>
<script type="text/javascript" src="js/script3.js"></script>
<!-- endbuild -->
Run
return gulp.src( './public/index.html')
.pipe( usemin({
js: [uglify(), rev()]
}))
.pipe( gulp.dest('./dist') );
After
<script type="text/javascript" src="js/app-d8ce9cc5.js"></script>
However, recently I've been using browserify, which builds the source tree via node-style require
statements.
Before
// index.html
<script type="text/javascript" src="js/app.js"></script>
// js/app.js
require('angular');
require('./ngmodules/customFilters');
require('./components/feature/feature');
Run
return browserify( './public/js/app.js' )
.bundle()
.pipe( source('bundle.js') )
.pipe( streamify(uglify()) )
.pipe( buffer() )
.pipe( rev() )
.pipe( gulp.dest('./dist/js') )
After
// index.html (no reference update)
<script type="text/javascript" src="js/bundle.js"></script>
The problem is if I use rev
I have no ability to hash/cachebust the file. Is there any way to use the two in tandem? Or a an easy way to point my dist/index.html
reference to bundle.js
to the hashed version? I've read the gulp-rev recommendations but they seem horrible in comparison.
For context, I'm using Python/Django/Jade/Sass/Compass in the project.