Super-fast alternative for minify-html-literals
.
import { minifyHTMLLiterals } from '@importantimport/minify-html-literals'
const result = minifyHTMLLiterals(
`function render(title, items) {
return html\`
<style>
.heading {
color: blue;
}
</style>
<h1 class="heading">\${title}</h1>
<ul>
\${items.map(item => {
return getHTML()\`
<li>\${item}</li>
\`;
})}
</ul>
\`;
}`,
)
console.log(result.code)
// function render(title, items) {
// return html`<style>.heading{color:#00f}</style><h1 class="heading">${title}</h1><ul>${items.map((item)=>{
// return getHTML()`
// <li>${item}</li>
// `;
// })}</ul>`;
// }
Super-fast alternative for rollup-plugin-minify-html-literals
.
// vite.config.ts
import minifyHTML from '@importantimport/unplugin-minify-html-literals'
import { defineConfig } from 'vite'
export default defineConfig({
...config,
plugins: [
minifyHTML.vite(),
...plugins,
],
})
licensed under the MIT.
partially copies code from the following projects, their licenses are listed in Third-party library licenses.
Project | License |
---|---|
asyncLiz/parse-literals | MIT |
asyncLiz/minify-html-literals | MIT |