grunt-ts icon indicating copy to clipboard operation
grunt-ts copied to clipboard

Offer minimize html support for the typescript html views

Open johnman opened this issue 9 years ago • 11 comments

I like the html support you have for grunt-ts and have used the features in the latest beta to create a custom template ts file.

A nice option would be to enable html minification so that the generated js would be smaller on larger views.

Nice work on grunt-ts!

johnman avatar Jul 30 '15 09:07 johnman

Are you talking about the htmlOutputTemplate option?

On Thu, Jul 30, 2015 at 11:21 AM johnman [email protected] wrote:

I like the html support you have for grunt-ts and have used the features in the latest beta to create a custom template ts file.

A nice option would be to enable html minification so that the generated js would be smaller on larger views.

Nice work on grunt-ts!

— Reply to this email directly or view it on GitHub https://github.com/TypeStrong/grunt-ts/issues/270.

davidLeonardi avatar Jul 30 '15 12:07 davidLeonardi

Yes I use htmlOutputTemplate and have a views task with the pattern to find all relevant html files with no source and compile set to false (a different build config builds all the ts including the html ts files).

johnman avatar Jul 31 '15 09:07 johnman

maybe some htmlmin options support in options so that we can optionally minify the html that will be within the ts property.

johnman avatar Jul 31 '15 09:07 johnman

+1, that would be really great. At the moment I prefer loading angular templates the "traditional" way, because I can mimimize them. If I could use htmlmin in grunt-ts, compiling to .ts would be the superior way for templates.

hoeni avatar Aug 04 '15 09:08 hoeni

Hi John and Hoeni,

I've been thinking about this for a little while. In my opinion minification has no place within grunt-ts, as grunt-ts does one thing: compilation to typescript.

I personally export to AMD modules and then the minification can be handled by means of my build system, in other cases a grunt watch task could pick up .ts files and minify html strings in them, but it's really not a concern of grunt-ts to minify html, as then we'd have to start minifying css as well, and there are a bazillion ways to do that, and so on.

I'd say more opinions are needed on this topic though.

davidLeonardi avatar Aug 04 '15 09:08 davidLeonardi

@nycdotnet any opinions?

davidLeonardi avatar Aug 04 '15 09:08 davidLeonardi

Hi sethx,

I don't think that grunt-ts should do the minification, as this is surely no fit (one tool, one task!). But it should spawn another minification tool for this.

As an example for a similar task see the ngtemplates module (https://github.com/ericclemmons/grunt-angular-templates). It takes HTML template files to build one huge (angular-)JS file from. It is able to use ngmin for compressing the templates to be stored in the JS.

hoeni avatar Aug 04 '15 10:08 hoeni

I'll investigate bundling html-min as it's already a grunt plugin. that makes more sense... But that requires config changes i'd guess. Am quite busy these days, hope to get to it during the weekend.

davidLeonardi avatar Aug 04 '15 10:08 davidLeonardi

Sorry, it was htmlmin in ng-templates not "ngmin" anyway :-)

hoeni avatar Aug 04 '15 12:08 hoeni

I would be willing to allow a plugin. Perhaps by passing a function in the Gruntfile to the html feature. Would that be useful? That way we could provide the support but not have to be in that business. Make sense?

nycdotnet avatar Aug 04 '15 12:08 nycdotnet

I'd advocate spawning off to a plugin to minify the html (spoke about this before) but I am not used to grunt yet, so docs / examples would be useful in my case :)

AnthoniG avatar Aug 12 '15 19:08 AnthoniG