boolean | Object | Function
The configs of html-rspack-plugin can be modified through tools.htmlPlugin
.
Rsbuild internally implements HTML-related features based on html-rspack-plugin. It is a fork of html-webpack-plugin, with the same features and options.
If you need to modify options such as title
, template
, templateParameters
, meta
, it is recommended to use the corresponding HTML configurations provided by Rsbuild first, such as html.title, html .template etc.
This is because Rsbuild provides some internal optimization processing for these HTML configurations. For example, if the HTML template used by the current project already contains the <title>
tag, then html.title
will not take effect.
When tools.htmlPlugin
is Object
type, the value will be merged with the default config via Object.assign
.
When tools.htmlPlugin
is a Function:
Setting tools.htmlPlugin
to false
can disable the built-in html-rspack-plugin
in Rsbuild, and no HTML files will be generated.
The filename
option can be used to modify the file name of the HTML output.
For example, in production mode, a hash
can be added to the file name:
Rsbuild currently does not minify HTML files. If you need to minify HTML files, you can use the rsbuild-plugin-html-minifier-terser plugin.