A Metalsmith plugin that minifies HTML files using kangax/html-minifier. Version 2.2.0 is the current stable release, with a low update cadence (last updated in 2018). Key differentiators: it integrates seamlessly with Metalsmith build pipelines, supports glob patterns for file selection, and provides sensible defaults while allowing full configuration of html-minifier options. It enables several optimizations by default (e.g., collapsing whitespace, removing comments), which users should disable explicitly if undesired. The plugin is lightweight with no runtime dependencies beyond metalsmith and html-minifier.
npm install metalsmith-html-minifier-multimatchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
This example shows how to use the plugin with a custom glob pattern and minifier options to disable comment removal while enabling whitespace collapse.
Evaluate newer minification libraries like html-minifier-terser.
Explicitly set unwanted options to false, e.g., { removeComments: false }.Test glob patterns with a small set of files first or use a clear pattern like '**/*.html'.
Update calls from .use(htmlMinifier({...})) to .use(htmlMinifier('**/*.html', {...})).Place this plugin after any plugin that may alter HTML content (e.g., template engines).
Ensure Node.js version supports ESM or use require() syntax: const htmlMinifier = require('metalsmith-html-minifier');Use a more inclusive pattern like '**/*.html' or verify the source directory path.
Run npm install html-minifier --save.