Strip HTML comments from Blaze templates in production


#1

I’m currently using Blaze templates, and have lots of HTML comments, often for commenting out parts of code that I need to stash.

I noticed that in production, these comments aren’t stripped. Not only does that increase the bundle size, but it leaks development info into the final public product.

Is there an easy way to minify Blaze templates when they’re compiled for production? At the very least stripping out HTML comments, but if it also strips unnecessary whitespaces / lines / etc. that would be great as well.

Or else, if this isn’t an automatic part of the meteor build chain, is there a tool out there that I can use to pre-process my Blaze templates before building the final production bundle?


#2

Simply use a Blaze comment block to wrap the html one:

{{!--
<!--
Html content here
-->
--}}

Or just use only the Blaze comments markup.