gulp-html-replace icon indicating copy to clipboard operation
gulp-html-replace copied to clipboard

Concat and replace files

Open nevf opened this issue 9 years ago • 3 comments

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.

nevf avatar Dec 21 '15 00:12 nevf

+1

jonatasleon avatar Feb 20 '16 16:02 jonatasleon

+1

zRosenthal avatar Jan 12 '17 20:01 zRosenthal

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.

bmacnaughton avatar Jan 17 '17 18:01 bmacnaughton