Registry / devops / html-rspack-plugin

html-rspack-plugin

JSON →
library6.1.9jsnpmunverified

Simplifies creation of HTML files to serve your Rspack bundles. This plugin is the Rspack equivalent of html-webpack-plugin, automatically injecting script and link tags into an HTML template. Current stable version is 6.1.9, released with support for Rspack core v1 and v2 (pre-release). It offers tight integration with Rspack's build system, supporting template engines, minification, and multi-page setups. The plugin is maintained actively by the Rspack team and provides a drop-in migration path from webpack to Rspack.

npm install html-rspack-plugin
INSTALL
IMPORT
SIG · HTML-RSPACK-PLUGIN
H
html-rspack-plugin
devopsjavascriptv6.1.9
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.

HtmlRspackPlugin
import HtmlRspackPlugin from 'html-rspack-plugin'
const { HtmlRspackPlugin } = require('html-rspack-plugin')
Default export; named import works in TS but default is preferred.
HtmlRspackPlugin (CommonJS)
const HtmlRspackPlugin = require('html-rspack-plugin').default
const { HtmlRspackPlugin } = require('html-rspack-plugin')
CJS require uses .default to access the default export since v6.
Options
import type { Options } from 'html-rspack-plugin'
Type-only import for configuration object shape.

Shows how to add html-rspack-plugin to a Rspack config, specifying a custom HTML template and output filename.

// rspack.config.js (or .mjs) import HtmlRspackPlugin from 'html-rspack-plugin'; import { defineConfig } from '@rspack/core'; export default defineConfig({ entry: './src/index.js', output: { filename: 'bundle.js', path: './dist' }, plugins: [ new HtmlRspackPlugin({ title: 'My App', template: './src/index.html', filename: 'index.html', }), ], }); // Then run `npx rspack build` to generate dist/index.html with script injected.
Debug
Known issues
breakingFrom v6.0.0, the package is ESM-only and requires Node >= 16.20.2.
fix
Update to Node >= 16.20.2 and use ESM imports (import/export). If using CJS, use dynamic import() or require('html-rspack-plugin').default.
affects: >=6.0.0
gotchadefault export changed from named export ('HtmlRspackPlugin') to default export. In CJS, you must access .default.
fix
Use `const HtmlRspackPlugin = require('html-rspack-plugin').default;`
affects: >=6.0.0
gotchaWhen using TypeScript, the plugin expects `@rspack/core` as a peer dependency. Type definitions may rely on Rspack's own types.
fix
Install @rspack/core in your project (devDependency).
affects: *
gotchaThe plugin does not support `html-webpack-plugin` options like `inject` or `chunksSortMode`; use Rspack-native options instead.
fix
Refer to the official documentation for Rspack-compatible options.
affects: *
deprecatedThe `compile` option has been deprecated and will be removed in v7.
fix
Remove the compile option; use Rspack's built-in minification or a custom minifier plugin.
affects: >=6.1.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'html-rspack-plugin'
package not installed or not in node_modules
fix
npm install html-rspack-plugin --save-dev
TypeError: HtmlRspackPlugin is not a constructor
Using default import incorrectly in CJS environment
fix
Use `const HtmlRspackPlugin = require('html-rspack-plugin').default;`
The 'template' option must be a string or a function
Passing incorrect type to template (e.g., an array)
fix
Specify a single string path to your HTML template file.
Upgrade
Version history
6.1.9latest on npm
Audit
Dependencies
@rspack/corerequiredPeer dependency required to run as a Rspack plugin
Agent activity
4 hits · last 30 days
node
4
Resources
html-rspack-plugin — npm install html-rspack-plugin · libregistry