website/docs/en/guide/tech/html.mdx
import { PackageManagerTabs } from '@theme';
Rspack can generate HTML through plugins and automatically inject emitted JavaScript and CSS assets. This guide covers two plugin options and how they differ in performance, features, and html-webpack-plugin compatibility.
Rspack provides two plugin options for generating HTML:
rspack.HtmlRspackPlugin is implemented in Rust and focuses on performance and common HTML generation needs.html-rspack-plugin is a JavaScript fork of html-webpack-plugin that prioritizes compatibility with its behavior.The built-in Rust implementation provides better build performance, especially when generating many HTML files. The JavaScript plugin also includes Rspack-specific optimizations but prioritizes compatibility.
rspack.HtmlRspackPlugin supports most html-webpack-plugin features, but cannot fully match all behaviors of the JavaScript implementation because its core logic runs in Rust. Use it when its features meet your needs and performance is the priority. Use html-rspack-plugin when migrating an existing html-webpack-plugin setup or when you need an unsupported option, capability, or behavior.
:::tip
rspack.HtmlRspackPlugin supports only a subset of EJS-style syntax and does not execute arbitrary JavaScript. For compatibility with html-webpack-plugin template processing behavior, use html-rspack-plugin and see its template documentation.
:::
rspack.HtmlRspackPlugin is included in @rspack/core, so no additional package is required.
import { rspack } from '@rspack/core';
export default {
plugins: [new rspack.HtmlRspackPlugin()],
};
For all configuration options, see the plugin documentation.
Install html-rspack-plugin separately:
import HtmlRspackPlugin from 'html-rspack-plugin';
export default {
plugins: [new HtmlRspackPlugin()],
};
For configuration options, see Options.
If you are migrating from html-webpack-plugin, see the webpack migration guide.