cfware / babel-plugin-template-html-minifier

Minify HTML in tagged template strings using html-minifier
MIT License
63 stars 4 forks source link

Use html from the in-project module #19

Closed Lodin closed 5 years ago

Lodin commented 5 years ago

Hello! I'm trying to use the approach I suggested in the Polymer/lit-html#568 but looks like this plugin does not support minifying html strings for the html imported from in-project files. Is it correct? If so, is it possible to add some functionality to enable processing for custom files, like regular expressions as modules? I would like to have something like the following:

{
  "plugins": [
    ["template-html-minifier", {
      "htmlMinifier": {
        "collapseWhitespace": true
      },
      "modules": {
        "\.\/config$": ["html"]
      }
    }]
  ]
}
coreyfarrell commented 5 years ago

Correct, this is not supported. I think #17 is the direction I will go in instead, so it will be possible to process all templates tagged with a specific name. For example to say that the following should be minified because it is tagged with html, regardless of how html was imported or declared:

html`<div >Minify this</div>`

Unfortunately I haven't had time to work on a patch to enable #17 yet.

Lodin commented 5 years ago

Thanks! I'll follow #17 then.