Minify CSS and HTML literals
npm install 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.
``bash`
$ npm i minify-literalsor
$ yarn add minify-literalsor
$ pnpm add minify-literals
| TypeScript |
` const source = let { code, map } = await minifyHTMLLiterals(source); console.log(code); Hello World;.foo{color:red};` |
`ts
export interface Options {
/**
* Minify HTML options, see https://github.com/terser/html-minifier-terser#options-quick-reference
* @default .//src/defaultOptions.ts
*/
minifyOptions?: Partial
/**
* Override the default strategy for how to minify HTML.
* More info:
* https://github.com/explodingcamera/esm/blob/main/packages/minify-literals/lib/strategy.ts
*
* @optional
*/
strategy: S;
}
``
- rollup-plugin-minify-template-literals - Rollup plugin for minifying HTML & CSS markup inside JavaScript/TypeScript template literal strings.
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:
- https://github.com/asyncLiz/minify-html-literals/issues/37
- https://github.com/asyncLiz/minify-html-literals/issues/45
- https://github.com/asyncLiz/minify-html-literals/issues/46
- https://github.com/asyncLiz/minify-html-literals/issues/40