babel-plugin-template-html-minifier
babel-plugin-template-html-minifier copied to clipboard
Minify all templates tagged with a certain tag
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.
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 has funded $38.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.
@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.
If that can work I have no objection, I suspect this can be done in a semver-minor.
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?