Registry / devops / html-minimizer-webpack-plugin

html-minimizer-webpack-plugin

JSON →
library6.0.0jsnpmunverified

Webpack plugin (v6.0.0) that minifies HTML files using one of three engines: swc (Rust), html-minifier-terser (JavaScript, default), or @minify-html/node (Rust). Integrates into Webpack's optimization.minimizer pipeline. Requires Node >= 20.9.0 (v6), Webpack 5.1+. Provides TypeScript types. Releases: v6.0.0 (Mar 2026), v5.0.x (2025), v5.0.0 (Jan 2024, dropped Node <18.12.0). Differentiators: multi-engine support, deep Webpack integration, asset/resource compatibility.

npm install html-minimizer-webpack-plugin
INSTALL
IMPORT
SIG · HTML-MINIMIZER-WEB
H
html-minimizer-webpack-plugin
devopsjavascriptv6.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HtmlMinimizerPlugin
import HtmlMinimizerPlugin from 'html-minimizer-webpack-plugin'
const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin')
CommonJS require works in Node, but ESM import is preferred. The package ships both ESM and CJS.
swcMinify
import HtmlMinimizerPlugin from 'html-minimizer-webpack-plugin'; const { swcMinify } = HtmlMinimizerPlugin;
import { swcMinify } from 'html-minimizer-webpack-plugin'
swcMinify and swcMinifyFragment are static properties on the default export, not named exports. Since v5.
swcMinifyFragment
HtmlMinimizerPlugin.swcMinifyFragment
import { swcMinifyFragment } from 'html-minimizer-webpack-plugin'
Available since v4.3.0. Also accessed via static property.

Basic configuration using default html-minifier-terser engine with custom options. Requires optimization.minimize: true.

// webpack.config.js (CommonJS) const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin'); module.exports = { optimization: { minimize: true, minimizer: [ new HtmlMinimizerPlugin({ minimizerOptions: { // html-minifier-terser options collapseWhitespace: true, removeComments: true, }, }), ], }, };
Debug
Known issues
breakingNode.js >= 20.9.0 required, dropped support for older versions.
fix
Upgrade Node.js to >=20.9.0 or stay on v5.x (requires Node >=18.12.0).
affects: >=6.0.0
breakingNode.js >= 18.12.0 required in v5.0.0.
fix
Upgrade Node.js to >=18.12.0 or use v4.x (Node 14+).
affects: >=5.0.0 <6.0.0
gotchaHTML is only minimized in production mode by default. In development, set optimization.minimize: true explicitly.
fix
Add optimization.minimize: true to webpack config to enable minification in non-production modes.
affects: >=4.0.0
gotchaThe plugin processes only assets emitted by other plugins like copy-webpack-plugin or html-webpack-plugin; it does not handle inline HTML in JavaScript.
fix
Ensure your HTML files are emitted as assets (e.g., via copy-webpack-plugin or html-webpack-plugin) before they reach the minimizer.
affects: >=4.0.0
gotchaWhen using @swc/html, minify option must be HtmlMinimizerPlugin.swcMinify or swcMinifyFragment; using a string 'swc' will not work.
fix
Pass the static property, e.g., minify: HtmlMinimizerPlugin.swcMinify.
affects: >=5.0.0
deprecatedThe option 'minimizerOptions' is incorrectly typed in some TypeScript versions; use 'options' instead (v5+).
fix
Use 'options' property for minimizer options in v6; check your TypeScript strictness.
affects: >=5.0.0 <6.0.0
Errors
Common errors & fixes
Error: HtmlMinimizerPlugin is not a constructor
Using named import instead of default import in CommonJS.
fix
Change to const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin');
TypeError: Cannot read properties of undefined (reading 'minify')
Plugin configured without proper minimizer function; default engine not found.
fix
Make sure you have installed html-minifier-terser (auto-installed) or specify minify option.
Module not found: Error: Can't resolve '@swc/html'
Missing optional dependency @swc/html when using swc minify.
fix
Run npm install @swc/html --save-dev
Upgrade
Version history
6.0.0latest on npm
Audit
Dependencies
webpackrequiredPeer dependency; required to run as a Webpack plugin
@swc/htmloptionalOptional: needed if using swc minify engine
@minify-html/nodeoptionalOptional: needed if using @minify-html/node minify engine
Agent activity
2 hits · last 30 days
node
2
Resources