rollup-plugin-minify-template-literals
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

rollup-plugin-minify-template-literals API Docs

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

Installation

$ npm i rollup-plugin-minify-template-literals
# or
$ yarn add rollup-plugin-minify-template-literals
# or
$ pnpm add rollup-plugin-minify-template-literals

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;
}

Related Packages

  • minify-literals - Minify HTML & CSS markup inside JavaScript/TypeScript template literal strings.

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.

Package Sidebar

Install

npm i rollup-plugin-minify-template-literals

Weekly Downloads

12

Version

1.1.7

License

MIT

Unpacked Size

18.3 kB

Total Files

9

Last publish

Collaborators

  • explodingcamera