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-pluginVerified import paths — ran on the pinned version, not inferred.
Basic configuration using default html-minifier-terser engine with custom options. Requires optimization.minimize: true.
Upgrade Node.js to >=20.9.0 or stay on v5.x (requires Node >=18.12.0).
Upgrade Node.js to >=18.12.0 or use v4.x (Node 14+).
Add optimization.minimize: true to webpack config to enable minification in non-production modes.
Ensure your HTML files are emitted as assets (e.g., via copy-webpack-plugin or html-webpack-plugin) before they reach the minimizer.
Pass the static property, e.g., minify: HtmlMinimizerPlugin.swcMinify.
Use 'options' property for minimizer options in v6; check your TypeScript strictness.
Change to const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin');Make sure you have installed html-minifier-terser (auto-installed) or specify minify option.
Run npm install @swc/html --save-dev