Registry / devops / grunt-contrib-htmlmin

grunt-contrib-htmlmin

JSON →
library3.1.0jsnpmunverified

Grunt plugin to minify HTML using html-minifier. Current stable version is 3.1.0 (released 2019-04-01), updated to html-minifier v4.0.0. Release cadence is low (2-3 years between major versions). Key differentiator: deeply integrated with Grunt build system, leverages battle-tested html-minifier with full options passthrough. Minimal overhead – just configure files and options. Alternatives include gulp-htmlmin or direct use of html-minifier. Requires Node.js >= 6.

npm install grunt-contrib-htmlmin
INSTALL
IMPORT
SIG · GRUNT-CONTRIB-HTML
G
grunt-contrib-htmlmin
devopsjavascriptv3.1.0
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.

grunt-contrib-htmlmin
grunt.loadNpmTasks('grunt-contrib-htmlmin');
const htmlmin = require('grunt-contrib-htmlmin');
This is a Grunt plugin, not a standalone library. Only load it via grunt.loadNpmTasks.
htmlmin task
grunt.initConfig({ htmlmin: { ... } });
grunt.initConfig({ 'grunt-contrib-htmlmin': { ... } });
Task name is 'htmlmin', not the full package name.
options
options: { removeComments: true, collapseWhitespace: true }
options: { removeComments: true, whitespace: true }
All options are passed directly to html-minifier. See https://github.com/kangax/html-minifier#options-quick-reference for available options.

Shows installation, configuration with html-minifier options, and registration for the htmlmin task.

npm install grunt grunt-contrib-htmlmin --save-dev // Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ htmlmin: { dist: { options: { removeComments: true, collapseWhitespace: true, minifyJS: true, minifyCSS: true }, files: { 'dist/index.html': 'src/index.html' } } } }); grunt.loadNpmTasks('grunt-contrib-htmlmin'); grunt.registerTask('default', ['htmlmin']); };
Debug
Known issues
breakingNode.js < 4 no longer supported since v2.0.0, Node.js < 6 no longer supported since v3.0.0.
fix
Upgrade to Node.js >= 6.
affects: >=2.0.0
gotchaOptions are passed directly to html-minifier; not all html-minifier options may be supported or work as expected.
fix
Refer to html-minifier documentation for option details.
affects: >=3.1.0
deprecatedGrunt ecosystem is mostly unmaintained; consider modern alternatives like Parcel/Webpack/Rollup.
fix
Migrate to a modern build tool if possible.
affects: >=0.0.0
Errors
Common errors & fixes
Warning: Task "htmlmin" not found. Use --force to continue.
Forgot to call grunt.loadNpmTasks('grunt-contrib-htmlmin');
fix
Add grunt.loadNpmTasks('grunt-contrib-htmlmin'); to Gruntfile.
Aborted due to warnings.
Grunt set to fatal warnings mode; an option is misconfigured or a file is missing.
fix
Check file paths and html-minifier options. Use grunt --force to temporarily bypass.
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
html-minifierrequiredcore minification library – all options are passed through to it
gruntrequiredpeer dependency – required for task registration
Agent activity
4 hits · last 30 days
node
4
Resources
grunt-contrib-htmlmin — npm install grunt-contrib-htmlmin · libregistry