0.0.5 • Published 4 months ago

minify-html-parts v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

minify-html-parts

This library extracts (tagged) template expressions from TypeScript code, which will be minified when shouldMinify returns true.

Can be used in lit-html or fast-element.

Example

import { minify } from "minify-html-parts";

const output = minify(input, {
  removeComments: true,
  removeAttributeQuotes: true,
  removeEmptyAttributeValues: true,
  shouldMinify(extractResult) {
    return extractResult.tag?.getText() === "html";
  },
});

Input

export const htmlResult = html`
  <my-element
    ${attr}
    id="${id}"
    class="x ${classes}"
    .property="${property}"
    @click="${onClick}"
  >
    <!-- comment -->
    ${html`
      <div>${textContent}</div>
    `}
  </my-element>
`;

Output

export const htmlResult = html`<my-element ${attr} id=${id} class="x ${classes}" .property=${property} @click=${onClick}> ${html`<div>${textContent}</div>`} </my-element>`;
0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

5 months ago

0.0.1

5 months ago