Highly configurable, well-tested, JavaScript-based HTML minifier with extensive optimization options
86
Create a small command-line helper that delegates to the HTML minifier CLI to process single files, STDIN/STDOUT streams, and whole directories. The helper must rely on the dependency's CLI binary (not its programmatic API) to apply minification behaviors defined in a supplied JSON config file.
<!DOCTYPE html><html><body><p>Sale!</p><script>console.log(1)</script></body></html>. @testsource set to - (read from STDIN) and no output path, piping the same HTML as above through the helper produces the minified HTML on STDOUT using the config rules (collapsed whitespace, removed comments). @testsrc/pages/index.html, src/pages/about.htm, and src/assets/logo.svg writes minified counterparts for the HTML/HTM files to the output directory, preserves relative paths, skips non-matching extensions (e.g., no output for the SVG), and applies the shared config to each processed file. @test@generates
export interface RunOptions {
source: string; // file path, directory path, or "-" for STDIN
output?: string; // file path, directory path, or undefined for STDOUT
configPath: string; // path to JSON config consumed by the underlying CLI
extensions?: string[]; // file extensions to include when processing directories
}
export async function run(options: RunOptions): Promise<void>;Command-line HTML minifier used to process files, STDIN, and directories via its provided binary. @satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-html-minifierdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9