Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rollup-plugin-minify-html-literals

asyncLiz54.4kMIT1.2.6TypeScript support: included

Rollup plugin to minify HTML template literal strings

rollup-plugin, minify, html, literal, literals, template, tagged, lit-html

readme

rollup-plugin-minify-html-literals

npm Build Status Coverage Status

Uses minify-html-literals to minify HTML and CSS markup inside JavaScript template literal strings.

Usage

import babel from 'rollup-plugin-babel';
import minifyHTML from 'rollup-plugin-minify-html-literals';
import { uglify } from 'rollup-plugin-uglify';

export default {
  entry: 'index.js',
  dest: 'dist/index.js',
  plugins: [
    minifyHTML(),
    // Order plugin before transpilers and other minifiers
    babel(),
    uglify()
  ]
};

By default, this will minify any tagged template literal string whose tag contains "html" or "css" (case insensitive). Additional options may be specified to control what templates should be minified.

Options

export default {
  entry: 'index.js',
  dest: 'dist/index.js',
  plugins: [
    minifyHTML({
      // minimatch of files to minify
      include: [],
      // minimatch of files not to minify
      exclude: [],
      // set to `true` to abort bundling on a minification error
      failOnError: false,
      // minify-html-literals options
      // https://www.npmjs.com/package/minify-html-literals#options
      options: null,

      // Advanced Options
      // Override minify-html-literals function
      minifyHTMLLiterals: null,
      // Override rollup-pluginutils filter from include/exclude
      filter: null
    })
  ]
};

Examples

Minify Polymer Templates

import minifyHTML from 'rollup-plugin-minify-html-literals';
import { defaultShouldMinify } from 'minify-html-literals';

export default {
  entry: 'index.js',
  dest: 'dist/index.js',
  plugins: [
    minifyHTML({
      options: {
        shouldMinify(template) {
          return (
            defaultShouldMinify(template) ||
            template.parts.some(part => {
              // Matches Polymer templates that are not tagged
              return (
                part.text.includes('<style') ||
                part.text.includes('<dom-module')
              );
            })
          );
        }
      }
    })
  ]
};

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.2.6 (2021-03-09)

Bug Fixes

  • add support for rollup 2.0.0 (f305718), closes #15
  • upate minify-html-literals to v1.3.5 (ab89bb0)

1.2.5 (2020-08-18)

Bug Fixes

  • update minify-html-literals to v1.3.2 (3408e5c)

1.2.4 (2020-06-10)

Bug Fixes

  • update minify-html-literals to v1.3.1 (a1eb2ef)

1.2.3 (2020-02-08)

Bug Fixes

  • update to minify-html-literals v1.3.0 (56cfb8d)

1.2.2 (2019-02-13)

Bug Fixes

  • failure to minify templates prefixed with comments (ea8c98e)

1.2.1 (2019-02-13)

Bug Fixes

  • remove source files from package (b784735)

1.2.0 (2019-02-13)

Bug Fixes

Features

  • minify CSS tagged template literals (6baf3c2)

1.1.2 (2018-11-29)

Bug Fixes

  • update minify-html-literals to 1.1.2 (2a26e9c)

1.1.1 (2018-10-25)

Bug Fixes

  • update minify-html-literals to 1.1.1 (6abe9bb)

1.1.0 (2018-10-24)

Features

  • update minify-html-literals to 1.1.0 (a1d9f1d)

1.0.7 (2018-10-05)

Bug Fixes

  • do not remove tag whitespace (7d4d289)

1.0.6 (2018-10-03)

Bug Fixes

  • do not collapse boolean attributes for Polymer binding syntax (8597d14)

1.0.5 (2018-09-27)

Bug Fixes

  • update parse-literals to minify escaped characters properly (ff2df26)

1.0.4 (2018-09-19)

Bug Fixes

  • update minify-html-literals to not sort attributes or classes (dc66de0)

1.0.3 (2018-09-19)

Bug Fixes

  • update minify-html-literals to use hires sourcemaps (8dcb055)

1.0.2 (2018-09-13)

Bug Fixes

  • do not require fileName in minify options (9543ef1)
  • update dependencies and typings (0a43630)

1.0.1 (2018-07-24)

Bug Fixes

  • typescript build issues (0d1b01f)

1.0.0 (2018-07-23)

Features