babel-plugin-template-html-minifier icon indicating copy to clipboard operation
babel-plugin-template-html-minifier copied to clipboard

Minify all templates tagged with a certain tag

Open LarsDenBakker opened this issue 6 years ago • 5 comments

Instead of specifying the module it should be exported from, I'd like to be able to just minify all templates prefixed with html and all templates prefixed with css.

LarsDenBakker avatar Mar 16 '19 10:03 LarsDenBakker

Currently the matching logic is based on bindings, so when the plugin encounters import {html} from 'lit-html';, this creates a binding on html. Then when a template is tagged with html it's not matched by name it's matched by comparing the binding.

I'll try to take a look at this as soon as I have a chance. I would like to maintain the current stricter functionality but I'm open to supporting this request.

coreyfarrell avatar Mar 19 '19 01:03 coreyfarrell

@coreyfarrell has funded $38.00 to this issue.


IssueHuntBot avatar May 07 '19 11:05 IssueHuntBot

@coreyfarrell just ran into a situation where I need this, since I have modules reexporting html from lit-html.

We could introduce a special case for * in the module key:

{
  "plugins": [
    ["template-html-minifier", {
      "modules": {
        "*": ["html"],
      },
      "strictCSS": true,
      "htmlMinifier": {
        "collapseWhitespace": true,
        "conservativeCollapse": true,
        "removeComments": true,
        "caseSensitive": true,
        "minifyCSS": true
      },
    }]
  ]
}

What do you think? I can work on this.

LarsDenBakker avatar May 11 '20 15:05 LarsDenBakker

If that can work I have no objection, I suspect this can be done in a semver-minor.

coreyfarrell avatar May 11 '20 15:05 coreyfarrell

I was looking for a replacement for the deprecated babel-plugin-html-template, a plugin that simply strips away html tags and minifies what is inside. Could it be done?

Juribiyan avatar Feb 11 '23 18:02 Juribiyan