Registry / devops / gulp-htmlmin-next

gulp-htmlmin-next

JSON →
library6.0.1jsnpmunverified

Gulp plugin to minify HTML using the popular html-minifier library. Current stable version is 6.0.1, with a release cadence that appears to be low (last major release October 2017). It passes through HTML files via Gulp pipeline and supports all options of the underlying html-minifier. Compared to alternatives like gulp-minify-html, gulp-htmlmin has the same API and has been more actively maintained in the past, though it relies on an older html-minifier. This package is ideal for optimizing HTML in a Gulp workflow, reducing file size with options like collapseWhitespace, removeComments, and minifyJS.

npm install gulp-htmlmin-next
INSTALL
IMPORT
SIG · GULP-HTMLMIN-NEXT
G
gulp-htmlmin-next
devopsjavascriptv6.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.

default
import htmlmin from 'gulp-htmlmin';
const htmlmin = require('gulp-htmlmin').default;
Default export is the plugin function.
require
const htmlmin = require('gulp-htmlmin');
CommonJS require returns the function directly.
gulp-htmlmin type import
import type { Options } from 'html-minifier';
import type { Options } from 'gulp-htmlmin';
TypeScript users should import types from html-minifier, not from gulp-htmlmin.

Basic Gulp task that minifies all HTML files from src/ to dist/ with collapseWhitespace and removeComments options.

const gulp = require('gulp'); const htmlmin = require('gulp-htmlmin'); gulp.task('minify', () => { return gulp.src('src/*.html') .pipe(htmlmin({ collapseWhitespace: true, removeComments: true })) .pipe(gulp.dest('dist')); });
Debug
Known issues
deprecatedPackage gulp-htmlmin is deprecated; use gulp-html-minifier-terser or gulp-htmlmin2.
fix
Switch to a maintained fork like gulp-html-minifier-terser.
affects: >=6.0.0
gotchahtml-minifier version pinned: gulp-htmlmin 6.0.1 depends on html-minifier ^3.5.8, which may have bugs not fixed.
fix
Consider using a forked plugin that uses a newer html-minifier version.
affects: 6.0.1
gotchaDo not report HTML parsing issues to this repo; they should be reported to html-minifier.
fix
Open issues at https://github.com/kangax/html-minifier/issues
affects: all
gotchaECMAScript 6 features in minification (e.g., arrow functions) require setting `minifyJS: true` in options.
fix
Enable minifyJS or use a separate JS minifier plugin.
affects: all
Errors
Common errors & fixes
Error: Module 'gulp-htmlmin' does not export default
Using ES6 import syntax without correct CJS interop in older Node versions.
fix
Use `import htmlmin from 'gulp-htmlmin'` with a bundler that supports CJS interop, or use require.
TypeError: htmlmin is not a function
Importing the module incorrectly (e.g., calling require('gulp-htmlmin').default when it's the default export).
fix
Use `const htmlmin = require('gulp-htmlmin');` or `import htmlmin from 'gulp-htmlmin';` if using ES modules.
AssertionError [ERR_ASSERTION]: Task function must be specified
Gulp 4 changed task registration; using gulp.task with arrow function may not return stream.
fix
Ensure the task function returns a stream: `return gulp.src(...)`.
Upgrade
Version history
6.0.1latest on npm
Audit
Dependencies
html-minifierrequiredCore library for HTML minification; gulp-htmlmin wraps html-minifier.
plugin-errorrequiredRequired for handling errors in Gulp plugins.
through2requiredUsed to create transform streams for Gulp.
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-htmlmin-next — npm install gulp-htmlmin-next · libregistry