gulp-html-replace
gulp-html-replace copied to clipboard
Concat and replace files
With gulp-userref I can concat script files into one, minify the result and replace the script tags with the new minified script. I can't see how that is possible in gulp-html-replace - is it?
OTH gulp-html-replace will let me replace a block with something I specify and gulp-userref doesn't do this.
I need to be able to perform both of these tasks.
Thanks for very useful gulp plugin.
+1
+1
I ended up writing gulp-markers because of this. I originally used gulp-html-replace but the code to handle optional file concatenation was convoluted and hard to maintain. gulp-markers is really a thin wrapper around RegExp.replace() that handles streams and buffers for gulp.
It's not as easy to use - you have to define your own markers (regular expressions) and replacements strings or function, just like RegExp replace. But it's this particular use, inserting non-concatenated files for development and concatenated files for production, that pushed me there.
If interested, here it is: https://github.com/bmacnaughton/gulp-markers/blob/master/README.md.
If you read to the bottom of my README you'll find that gulp-html-replace was what got me started down this whole path. I owe a debt to VFK for kicking this off and helping me get started in the whole area.