website/docs/en/guide/tech/html.mdx
Rspack can generate HTML files for your application and automatically inject the emitted JavaScript and CSS assets. This is useful for production builds where asset filenames often include content hashes, because the generated HTML will always reference the latest build outputs.
Rspack provides two plugin options for generating HTML:
HtmlRspackPlugin is optimized for performance and common HTML generation needs.HtmlWebpackPlugin is suitable when you need broader webpack ecosystem compatibility or features that are not yet implemented by HtmlRspackPlugin.If you're not sure which plugin to choose, see the comparison between HtmlRspackPlugin and HtmlWebpackPlugin to understand their differences in performance, features, and compatibility.
HtmlRspackPlugin is a high-performance HTML plugin implemented in Rust, offering significantly better build performance than the HtmlWebpackPlugin, especially when building a large number of HTML files.
import { rspack } from '@rspack/core';
export default {
plugins: [new rspack.HtmlRspackPlugin()],
};
For all configuration options, see the plugin documentation.
Rspack is fully compatible with HtmlWebpackPlugin.
import HtmlWebpackPlugin from 'html-webpack-plugin';
export default {
plugins: [new HtmlWebpackPlugin()],
};
For all configuration options, see the plugin documentation.