Registry / devops / html-minifier-loader

html-minifier-loader

JSON →
library1.4.1jsnpmunverified

Webpack loader that minifies HTML using html-minifier. Current stable version 1.4.1 (last release ~2017). No active maintenance; outdated compared to modern alternatives. Key differentiator: integrates html-minifier as a webpack loader with query params support. Requires peer dependency html-minifier. Note: raw-loader usage example implies raw output; loader is synchronous and not compatible with webpack 4+ loaders API without adaptation.

npm install html-minifier-loader
INSTALL
IMPORT
SIG · HTML-MINIFIER-LOAD
H
html-minifier-loader
devopsjavascriptv1.4.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.

loader
import htmlMinifierLoader from 'html-minifier-loader'
const loader = require('html-minifier-loader')
Used programmatically as a function; typically invoked via webpack config, not direct require.
default
import loader from 'html-minifier-loader'
import { loader } from 'html-minifier-loader'
The package exports a single loader function as default export.
Options
import type { Options } from 'html-minifier'
import { Options } from 'html-minifier-loader'
Type definitions exist only for html-minifier, not this loader.

Example webpack config using html-minifier-loader with raw-loader and custom html-minifier options.

// webpack.config.js const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, module: { rules: [ { test: /\.html$/, use: [ 'raw-loader', { loader: 'html-minifier-loader', options: { removeComments: true, collapseWhitespace: true, conservativeCollapse: true } } ] } ] } };
Debug
Known issues
deprecatedPackage is unmaintained since 2017; use html-minimizer-webpack-plugin instead.
fix
Migrate to html-minimizer-webpack-plugin (webpack 5+).
affects: >=1.0.0
breakingWebpack 4+ loader API changes: must use `this.async()` for async loaders; this loader is synchronous.
fix
Consider using html-loader with postprocess or a modern alternative.
affects: >=1.0.0
gotchaOptions must be passed via `options` key in webpack config, not top-level 'html-minifier-loader' property (deprecated config style).
fix
Use `{ loader: 'html-minifier-loader', options: { ... } }` in `use` array.
affects: >=1.0.0
deprecatedRequires raw-loader to output raw string; html-loader v2+ can emit raw strings without raw-loader.
fix
Use html-loader with `esModule: false` and `sources: false` options.
affects: >=1.0.0
gotchaPackage does not support ES module exports; designed for CJS webpack configs.
fix
Use webpack's `resolve.fallback` if using ESM configs.
affects: >=1.0.0
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
No loader rule for .html files or incorrect chaining order.
fix
Add raw-loader before html-minifier-loader in use array.
Error: options/query provided without loader (continue line)
Deprecated config syntax in webpack 4+.
fix
Use `{ loader: 'html-minifier-loader', options: { ... } }` inside `rules[].use`.
Upgrade
Version history
1.4.1latest on npm
Audit
Dependencies
html-minifierrequiredpeer dependency; performs actual minification
Agent activity
4 hits · last 30 days
node
4
Resources
html-minifier-loader — npm install html-minifier-loader · libregistry