0.0.5 • Published 4 months ago

rollup-plugin-minify-html-parts v0.0.5

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

rollup-plugin-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

Rollup config

import { minifyHtmlParts } from "rollup-plugin-minify-html-parts";

export default {
  // ...
  plugins: [
    minifyHtmlParts({
      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