rollup-plugin-html-literals

A Rollup plugin to minify html template literals

Usage no npm install needed!

<script type="module">
  import rollupPluginHtmlLiterals from 'https://cdn.skypack.dev/rollup-plugin-html-literals';
</script>

README

rollup-plugin-html-literals

A Rollup plugin to minify html template literals

Actions License Donate


Usage

import template from "rollup-plugin-html-literals";

export default {
    input: "index.js",
    output: { file: "dist/index.js", format: "esm" },
    plugins: [ template() ]
};

This will minify any template literal that is tagged with html.

NOTICE: This plugin should be used before transpiling.


Options

include

Type: array or string Default: []

A single file, or array of files to include when minifying.

exclude

Type: array or string Default: []

A single file, or array of files to exclude when minifying.

failOnError,

Type: boolean Default: false

If true, will throw an error if any errors were found.

options

Type: Object Default: null

Specify options for minify-html-literals

minifyHTMLLiterals

Type: function Default: null

Override the minification function.


Why

Projects such as lit-html make use of template literals, and in order to decrease bundle size, you need to minify the html markup you write in those template literals. The current solution for rollup, appears to be rollup-plugin-minify-html-literals but this plugin does not support Rollup v2, and instead is built to support Rollup v0. This plugin acts to solve the compatiblity issue, support newer versions of Rollup and maintain active support.


Reporting Issues

If you are having trouble getting something to work with this plugin or run into any problems, you can create a new Issue.

If this plugin does not fit your needs or is missing a feature you would like to see, let us know! We would greatly appreciate your feedback on it.


License

rollup-plugin-html-literals is licensed under the terms of the MIT license.