Registry / devops / gulp-htmlmin

gulp-htmlmin

JSON →
library5.0.1jsnpmunverified

A Gulp plugin for minifying HTML files using html-minifier (v5.0.1, last updated 2018). It wraps the popular html-minifier library, providing a simple way to integrate HTML minification into Gulp build pipelines. Supports all html-minifier options such as collapseWhitespace, removeComments, minifyCSS, and more. The plugin is stable but currently in maintenance mode with no recent updates; users may consider alternatives like gulp-html-minifier-terser or direct use of html-minifier-terser for newer features.

npm install gulp-htmlmin
INSTALL
IMPORT
SIG · GULP-HTMLMIN
G
gulp-htmlmin
devopsjavascriptv5.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

htmlmin
const htmlmin = require('gulp-htmlmin');
import htmlmin from 'gulp-htmlmin';
Package does not ship ESM; CommonJS only.
gulp
const gulp = require('gulp');
import gulp from 'gulp';
Gulp v4 still widely used with CommonJS; ESM support is experimental.
htmlmin default export
const htmlmin = require('gulp-htmlmin');
const { htmlmin } = require('gulp-htmlmin');
Default export is the function; named export does not exist.

Gulp task that minifies all HTML files from src/ to dist/ using common html-minifier options.

const gulp = require('gulp'); const htmlmin = require('gulp-htmlmin'); gulp.task('minify-html', () => { return gulp.src('src/**/*.html') .pipe(htmlmin({ collapseWhitespace: true, removeComments: true, minifyCSS: true, minifyJS: true })) .pipe(gulp.dest('dist')); }); exports.default = gulp.series('minify-html');
Debug
Known issues
deprecatedgulp-htmlmin is in maintenance mode; no updates since 2018. Consider using html-minifier-terser via gulp-html-minifier-terser.
fix
Switch to gulp-html-minifier-terser or use html-minifier-terser directly.
affects: >=5.0.0
gotchaSome html-minifier options may cause unexpected behavior or break HTML structure; always test output.
fix
Review html-minifier docs and test pages with various options like collapseWhitespace: true.
affects: *
gotchaUsing 'minifyCSS' and 'minifyJS' can change CSS and JS inline content; may break dynamic code.
fix
Set minifyCSS/minifyJS to false if inline sections contain sensitive or dynamic code.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'gulp-htmlmin'
Package not installed or missing from node_modules.
fix
Run 'npm install gulp-htmlmin --save-dev'
TypeError: htmlmin is not a function
Incorrect import style; trying to destructure default export.
fix
Use 'const htmlmin = require('gulp-htmlmin');' instead of destructuring.
Error: Gulp plugin requires a callback, promise or stream.
Missing return statement or incorrect stream handling.
fix
Ensure the task function returns the stream: 'return gulp.src(...).pipe(htmlmin())...'
Upgrade
Version history
5.0.1latest on npm
Audit
Dependencies
html-minifierrequiredCore minification engine; all minification logic delegated to this package.
plugin-errorrequiredStandard Gulp plugin error handling.
through2requiredStream transformation for Gulp streams.
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-htmlmin — npm install gulp-htmlmin · libregistry