Registry / devops / html-render-webpack-plugin

html-render-webpack-plugin

JSON →
library3.0.2jsnpmunverified

Webpack plugin (v3.0.2, latest) for rendering static HTML files using JavaScript, designed for multi-config webpack builds. Supports code-splitting, dynamic imports, and asset injection from separate webpack compilation stats. Differentiates from html-webpack-plugin by supporting multiple configurations (e.g., one for browser assets, one for node rendering) and allowing custom render functions with access to webpack stats. Requires webpack 5 (v3.x) and express as a peer dependency. Active development with recent maintenance updates.

npm install html-render-webpack-plugin
INSTALL
IMPORT
SIG · HTML-RENDER-WEBPAC
H
html-render-webpack-plugin
devopsjavascriptv3.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

HtmlRenderPlugin
import { HtmlRenderPlugin } from 'html-render-webpack-plugin'
const HtmlRenderPlugin = require('html-render-webpack-plugin')
Since v3.0.0, the plugin is exported as both named and default export. CommonJS require must use destructuring (e.g., const { HtmlRenderPlugin } = require('html-render-webpack-plugin')).
default (HtmlRenderPlugin)
import HtmlRenderPlugin from 'html-render-webpack-plugin'
const HtmlRenderPlugin = require('html-render-webpack-plugin').default
Default export is available since v3.0.0 for ESM imports. Both named and default export work.
HtmlRenderPlugin instance
const htmlRenderPlugin = new HtmlRenderPlugin(); module.exports.plugins = [htmlRenderPlugin.rendererPlugin]
module.exports.plugins = [new HtmlRenderPlugin()] // This adds the whole instance as a plugin, which is incorrect
The instance provides .rendererPlugin and .statsCollectorPlugin. Not the instance itself.

Shows a minimal single-config setup for html-render-webpack-plugin with a render function entry.

// webpack.config.js (single config) const { HtmlRenderPlugin } = require('html-render-webpack-plugin'); // Your render function (src/render.js) // export default ({ assetsByChunkName }) => `<html><body><script src="${assetsByChunkName.main}"></script></body></html>`; module.exports = { entry: { main: './src/index.js', render: './src/render.js' }, target: 'node', // because render runs in node plugins: [ new HtmlRenderPlugin().rendererPlugin ] };
Debug
Known issues
breakingv3.0.0 changed the plugin export from default to named export. CommonJS require destructuring is required.
fix
Use `const { HtmlRenderPlugin } = require('html-render-webpack-plugin');`
affects: >=3.0.0
breakingv3.0.0 supports webpack 5 only; webpack 4 support dropped.
fix
Upgrade to webpack 5 or use v2.x (html-render-webpack-plugin@2)
affects: >=3.0.0
gotchaDo not pass the HtmlRenderPlugin instance directly to plugins array; use .rendererPlugin or .statsCollectorPlugin.
fix
Create an instance and use `.rendererPlugin` for the rendering config, `.statsCollectorPlugin` for stats collection in other configs.
affects: >=0.0.0
gotchaThe plugin uses express as a peer dependency; not installing it will cause runtime errors.
fix
Run `npm install express` or add it to your project dependencies.
affects: >=3.0.0
deprecatedThe `render` property on the instance (e.g., `new HtmlRenderPlugin().render`) is deprecated in favor of `.rendererPlugin`.
fix
Use `new HtmlRenderPlugin().rendererPlugin` instead.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'html-render-webpack-plugin'
Plugin not installed or not resolved in node_modules.
fix
Run `npm install html-render-webpack-plugin`.
TypeError: HtmlRenderPlugin is not a constructor
Using CommonJS require without destructuring after v3.0.0.
fix
Change `const HtmlRenderPlugin = require('html-render-webpack-plugin')` to `const { HtmlRenderPlugin } = require('html-render-webpack-plugin')`.
Error: Plugin tried to add itself twice with the same name 'HtmlRenderPlugin'
Adding the same plugin instance to multiple webpack configs incorrectly.
fix
Create separate instances for each config or use .statsCollectorPlugin for additional configs.
Error: Cannot read property 'main' of undefined
Render function expects assetsByChunkName but no stats collector plugin was added.
fix
Add `htmlRenderPlugin.statsCollectorPlugin` to the client config's plugins list.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies
expressrequiredUsed internally to run a local express server for rendering HTML during the webpack build process.
Agent activity
6 hits · last 30 days
node
6
Resources
html-render-webpack-plugin — npm install html-render-webpack-plugin · libregistry