minify-literals
Minify HTML & CSS markup inside JavaScript/TypeScript template literal strings.
Uses html-minifier-terser to minify HTML and clean-css to minify CSS.
Installation
$ npm i minify-literals
$ yarn add minify-literals
$ pnpm add minify-literals
Usage
TypeScript |
import { minifyHTMLLiterals } from "minify-literals";
const source = `
const el = html\`<div > <h1> Hello World </h1 > </div>\`;
const css = css\` .foo { color: red; } \`;
`;
let { code, map } = await minifyHTMLLiterals(source);
console.log(code);
console.log(map);
|
Options
export interface Options {
minifyOptions?: Partial<minify.Options>;
strategy: S;
}
Related Packages
Credits
This package is based on minify-html-literals by Elizabeth Mitchell
I've fixed a few bugs, ported it to ES modules, and refactored it a bit.
Some of the fixed bugs: