rollup-plugin-minify-html-literals
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(),
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({
include: [],
exclude: [],
failOnError: false,
options: null,
minifyHTMLLiterals: null,
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 => {
return (
part.text.includes('<style') ||
part.text.includes('<dom-module')
);
})
);
}
}
})
]
};