Webpack loader that exports HTML as a string, automatically resolving and processing references to assets like images, scripts, and stylesheets. Current stable release is v5.1.0 (July 2024), with breaking changes in v5.0.0 (Node.js >=18.12.0 required) and v4.0.0 (Node.js >=14.15.0, updated parse5). Key differentiators: supports sources configuration for custom tag/attribute handling, preprocessor and postprocessor hooks, and integrates with webpack's asset modules. Actively maintained under webpack-contrib, with frequent updates and community support.
npm install html-loaderVerified import paths — ran on the pinned version, not inferred.
Configures html-loader in webpack to process HTML files, resolve image sources, and minimize output.
Upgrade Node.js to >=18.12.0
Upgrade Node.js to >=14.15.0
Test HTML parsing with new parse5 version; adjust HTML if needed
Replace 'interpolate' with 'preprocessor' function
Configure asset modules or file-loader for referenced assets
Use path.resolve(path.dirname(resourcePath), value) if needed
Add { test: /\.html$/i, loader: 'html-loader' } to module.rules in webpack.config.jsRun 'npm install --save-dev html-loader' or 'yarn add -D html-loader'
Check the options object matches the documented schema (sources, preprocessor, postprocessor, minimize, esModule)
Replace 'interpolate' with a 'preprocessor' function