{"id":41479,"library":"metalsmith-html-minifier-multimatch","title":"Metalsmith HTML Minifier","description":"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.","status":"maintenance","version":"2.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/whymarrh/metalsmith-html-minifier","tags":["javascript"],"install":[{"cmd":"npm install metalsmith-html-minifier-multimatch","lang":"bash","label":"npm"},{"cmd":"yarn add metalsmith-html-minifier-multimatch","lang":"bash","label":"yarn"},{"cmd":"pnpm add metalsmith-html-minifier-multimatch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency – the plugin is designed to be used as a Metalsmith plugin.","package":"metalsmith","optional":false},{"reason":"Core dependency – provides the HTML minification logic.","package":"html-minifier","optional":false}],"imports":[{"note":"Default import is the plugin function. CJS require() also works but ESM is preferred for new projects.","wrong":"const htmlMinifier = require('metalsmith-html-minifier')","symbol":"default (function)","correct":"import htmlMinifier from 'metalsmith-html-minifier'"},{"note":"Metalsmith is a separate package, needed to use this plugin.","wrong":"","symbol":"Metalsmith","correct":"import Metalsmith from 'metalsmith'"},{"note":"TypeScript users can import the options type from html-minifier for type safety.","wrong":"","symbol":"Options interface","correct":"import type { Options } from 'html-minifier'"}],"quickstart":{"code":"import Metalsmith from 'metalsmith';\nimport htmlMinifier from 'metalsmith-html-minifier';\n\nMetalsmith(__dirname)\n  .use(htmlMinifier('*.html', {\n    removeComments: false,\n    collapseWhitespace: true,\n  }))\n  .build((err) => {\n    if (err) throw err;\n    console.log('Build complete!');\n  });","lang":"typescript","description":"This example shows how to use the plugin with a custom glob pattern and minifier options to disable comment removal while enabling whitespace collapse."},"warnings":[{"fix":"Evaluate newer minification libraries like html-minifier-terser.","message":"html-minifier is no longer actively maintained; consider using html-minifier-terser or other alternatives.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Explicitly set unwanted options to false, e.g., { removeComments: false }.","message":"Certain optimizations are enabled by default (e.g., collapseBooleanAttributes, removeComments) which may break functionality like conditional comments or AngularJS directives.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Test glob patterns with a small set of files first or use a clear pattern like '**/*.html'.","message":"The glob pattern is passed directly to multimatch; incorrect patterns may result in no files being minified.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Update calls from .use(htmlMinifier({...})) to .use(htmlMinifier('**/*.html', {...})).","message":"Version 2.0.0 changed the API from accepting an options object as first argument to requiring a glob string first.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Place this plugin after any plugin that may alter HTML content (e.g., template engines).","message":"The plugin operates on the file contents after other plugins; ordering matters if other plugins modify HTML.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.2.0':14 '2018':28 'allow':49 'beyond':83 'build':36 'cadenc':24 'collaps':64 'comment':67 'configur':51 'current':17 'default':47,62 'depend':82 'differenti':30 'disabl':71 'e.g':63 'enabl':58 'explicit':72 'file':10,42 'full':50 'glob':39 'html':2,9,54,87 'html-minifi':53,86 'integr':32 'javascript':89 'kangax/html-minifier':12 'key':29 'last':25 'lightweight':78 'low':22 'metalsmith':1,5,35,84 'minifi':3,8,55,88 'optim':60 'option':56 'pattern':40 'pipelin':37 'plugin':6,76 'provid':45 'releas':19 'remov':66 'runtim':81 'seamless':33 'select':43 'sensibl':46 'sever':59 'stabl':18 'support':38 'undesir':74 'updat':23,26 'use':11 'user':69 'version':13 'whitespac':65","created_at":"2026-06-04T18:52:37.009069+00:00","updated_at":"2026-06-04T18:52:37.009069+00:00","problems":[{"fix":"Ensure Node.js version supports ESM or use require() syntax: const htmlMinifier = require('metalsmith-html-minifier');","cause":"Using ESM import when the package is imported as default but the module system is misconfigured.","error":"TypeError: htmlMinifier is not a function"},{"fix":"Use a more inclusive pattern like '**/*.html' or verify the source directory path.","cause":"The glob pattern does not match any files in the Metalsmith source directory.","error":"Error: No files matched pattern '*.html'"},{"fix":"Run npm install html-minifier --save.","cause":"Missing dependency html-minifier.","error":"Unhandled rejection: Error: Cannot find module 'html-minifier'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/adenin-sites/metalsmith-html-minifier","github":"git://github.com/whymarrh/metalsmith-html-minifier","docs":null,"changelog":null,"pypi":null,"npm":"metalsmith-html-minifier-multimatch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}