Registry /
devops / minify-html-webpack-plugin
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MinifyHtmlWebpackPlugin
✓ const MinifyHtmlWebpackPlugin = require('minify-html-webpack-plugin');
✗ import MinifyHtmlWebpackPlugin from 'minify-html-webpack-plugin';
Package does not provide ESM exports; CommonJS require is required.
MinifyHtmlWebpackPlugin
✓ const MinifyHtmlWebpackPlugin = require('minify-html-webpack-plugin');
✗ const { MinifyHtmlWebpackPlugin } = require('minify-html-webpack-plugin');
Export is default, not named. Destructuring will yield undefined.
MinifyHtmlWebpackPlugin
✓ new MinifyHtmlWebpackPlugin({ src: '...', dest: '...' })
✗ new MinifyHtmlWebpackPlugin()
Constructor requires at least `src` and `dest` options; otherwise it errors.
Basic config to minify HTML files from src/html to dist/html after webpack build.
// webpack.config.js
const path = require('path');
const MinifyHtmlWebpackPlugin = require('minify-html-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
plugins: [
new MinifyHtmlWebpackPlugin({
src: path.resolve(__dirname, 'src/html'),
dest: path.resolve(__dirname, 'dist/html'),
rules: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
minifyJS: true,
minifyCSS: true
}
})
]
};
Errors
Common errors & fixes
Error: Cannot find module 'html-minifier'
Missing dependency; html-minifier is not automatically installed.
fixRun 'npm install html-minifier --save-dev'
TypeError: Cannot read property 'replace' of undefined
searchAndReplace array entry missing 'search' or 'replace' property.
fixEnsure each object in searchAndReplace has both 'search' and 'replace' fields.
MinifyHtmlWebpackPlugin is not a constructor
Using default import instead of require in CommonJS.
fixUse 'const MinifyHtmlWebpackPlugin = require('minify-html-webpack-plugin');' The 'src' directory does not exist
Provided src path is invalid or does not exist.
fixEnsure src directory exists and path is correct.
Audit
Dependencies
html-minifierrequiredCore library for HTML minification