{"id":20105,"library":"html-render-webpack-plugin","title":"html-render-webpack-plugin","description":"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.","status":"active","version":"3.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/jahredhope/html-render-webpack-plugin","tags":["javascript","html","static","plugin","webpack"],"install":[{"cmd":"npm install html-render-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add html-render-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add html-render-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally to run a local express server for rendering HTML during the webpack build process.","package":"express","optional":false}],"imports":[{"note":"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')).","wrong":"const HtmlRenderPlugin = require('html-render-webpack-plugin')","symbol":"HtmlRenderPlugin","correct":"import { HtmlRenderPlugin } from 'html-render-webpack-plugin'"},{"note":"Default export is available since v3.0.0 for ESM imports. Both named and default export work.","wrong":"const HtmlRenderPlugin = require('html-render-webpack-plugin').default","symbol":"default (HtmlRenderPlugin)","correct":"import HtmlRenderPlugin from 'html-render-webpack-plugin'"},{"note":"The instance provides .rendererPlugin and .statsCollectorPlugin. Not the instance itself.","wrong":"module.exports.plugins = [new HtmlRenderPlugin()] // This adds the whole instance as a plugin, which is incorrect","symbol":"HtmlRenderPlugin instance","correct":"const htmlRenderPlugin = new HtmlRenderPlugin();\nmodule.exports.plugins = [htmlRenderPlugin.rendererPlugin]"}],"quickstart":{"code":"// webpack.config.js (single config)\nconst { HtmlRenderPlugin } = require('html-render-webpack-plugin');\n\n// Your render function (src/render.js)\n// export default ({ assetsByChunkName }) => `<html><body><script src=\"${assetsByChunkName.main}\"></script></body></html>`;\n\nmodule.exports = {\n  entry: {\n    main: './src/index.js',\n    render: './src/render.js'\n  },\n  target: 'node', // because render runs in node\n  plugins: [\n    new HtmlRenderPlugin().rendererPlugin\n  ]\n};","lang":"javascript","description":"Shows a minimal single-config setup for html-render-webpack-plugin with a render function entry."},"warnings":[{"fix":"Use `const { HtmlRenderPlugin } = require('html-render-webpack-plugin');`","message":"v3.0.0 changed the plugin export from default to named export. CommonJS require destructuring is required.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade to webpack 5 or use v2.x (html-render-webpack-plugin@2)","message":"v3.0.0 supports webpack 5 only; webpack 4 support dropped.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Create an instance and use `.rendererPlugin` for the rendering config, `.statsCollectorPlugin` for stats collection in other configs.","message":"Do not pass the HtmlRenderPlugin instance directly to plugins array; use .rendererPlugin or .statsCollectorPlugin.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Run `npm install express` or add it to your project dependencies.","message":"The plugin uses express as a peer dependency; not installing it will cause runtime errors.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use `new HtmlRenderPlugin().rendererPlugin` instead.","message":"The `render` property on the instance (e.g., `new HtmlRenderPlugin().render`) is deprecated in favor of `.rendererPlugin`.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'5':69 'access':63 'activ':77 'allow':58 'asset':31,52 'browser':51 'build':23 'code':26 'code-split':25 'compil':36 'config':21 'configur':47 'custom':59 'depend':76 'design':17 'develop':78 'differenti':38 'dynam':28 'e.g':48 'express':72 'file':14 'function':61 'html':2,13,41,84 'html-render-webpack-plugin':1 'html-webpack-plugin':40 'import':29 'inject':32 'javascript':16,83 'latest':9 'mainten':81 'multi':20 'multi-config':19 'multipl':46 'node':55 'one':49,53 'peer':75 'plugin':5,7,43,86 'recent':80 'render':3,11,56,60 'requir':67 'separ':34 'split':27 'stat':37,66 'static':12,85 'support':24,45 'updat':82 'use':15 'v3.0.2':8 'v3.x':70 'webpack':4,6,22,35,42,65,68,87","created_at":"2026-04-25T11:21:20.997415+00:00","updated_at":"2026-04-25T11:21:20.997415+00:00","problems":[{"fix":"Run `npm install html-render-webpack-plugin`.","cause":"Plugin not installed or not resolved in node_modules.","error":"Error: Cannot find module 'html-render-webpack-plugin'"},{"fix":"Change `const HtmlRenderPlugin = require('html-render-webpack-plugin')` to `const { HtmlRenderPlugin } = require('html-render-webpack-plugin')`.","cause":"Using CommonJS require without destructuring after v3.0.0.","error":"TypeError: HtmlRenderPlugin is not a constructor"},{"fix":"Create separate instances for each config or use .statsCollectorPlugin for additional configs.","cause":"Adding the same plugin instance to multiple webpack configs incorrectly.","error":"Error: Plugin tried to add itself twice with the same name 'HtmlRenderPlugin'"},{"fix":"Add `htmlRenderPlugin.statsCollectorPlugin` to the client config's plugins list.","cause":"Render function expects assetsByChunkName but no stats collector plugin was added.","error":"Error: Cannot read property 'main' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jahredhope/html-render-webpack-plugin","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/html-render-webpack-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}