JSPM

rollup-plugin-minify-html-parts

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q38372F
  • License MIT

Minify HTML in (tagged) template expressions

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rollup-plugin-minify-html-parts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    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.type === "TaggedTemplateExpression" &&
              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>`;