JSPM

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

A Vite/Rollup plugin that minifies template literals.

Package Exports

  • rollup-plugin-minify-template-literals
  • rollup-plugin-minify-template-literals/dist/rollup-plugin-minify-template-literals.cjs
  • rollup-plugin-minify-template-literals/dist/rollup-plugin-minify-template-literals.js

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-template-literals) 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-template-literals API Docs

Minify HTML & CSS markup inside JavaScript/TypeScript template literal strings - for vite and rollup.

Usage

Vite

// vite.config.ts
import { defineConfig } from "vite";
import { minifyTemplateLiterals } from "rollup-plugin-minify-template-literals";

export default defineConfig({
  plugins: [minifyTemplateLiterals()],
});

Rollup

// rollup.config.js
import { minifyTemplateLiterals } from "rollup-plugin-minify-template-literals";

export default {
  plugins: [minifyTemplateLiterals()],
};

ES5 Support

Be sure to minify template literals before transpiling to ES5. Otherwise, the API will not be able to find any template literal (${}) strings.

Options

export interface Options {
  /**
   * Pattern or array of patterns of files to minify.
   */
  include?: string | string[];
  /**
   * Pattern or array of patterns of files not to minify.
   */
  exclude?: string | string[];
  /**
   * Minify options, see
   * https://github.com/explodingcamera/esm/tree/main/packages/minify-literals#options.
   */
  options?: Partial<minify.Options>;
  /**
   * If true, any errors while parsing or minifying will abort the bundle
   * process. Defaults to false, which will only show a warning.
   */
  failOnError?: boolean;
  /**
   * Override minify-html-literals function.
   */
  minifyHTMLLiterals?: typeof minify.minifyHTMLLiterals;
  /**
   * Override include/exclude filter.
   */
  filter?: (id: string) => boolean;
}

Credits

This package is based on rollup-plugin-minify-html-literals by Elizabeth Mitchell. I've fixed a few bugs, ported it to ES modules, and refactored it a bit.