Object | Function
Configure the <meta>
tag of the HTML.
If the HTML template used in the current project already contains the charset or viewport meta tags, then the tags in the HTML template take precedence.
When the value
of a meta
object is a string, the key
of the object is automatically mapped to name
, and the value
is mapped to content
.
For example to set description:
The generated meta
tag in HTML is:
When the value
of a meta
object is an object, the key: value
of the object is mapped to the attribute of the meta
tag.
In this case, the name
and content
properties will not be set by default.
For example to set charset
:
The meta
tag in HTML is:
When html.meta
is of type Function
, the function receives an object as an argument with the following properties:
value
: the default meta configuration of Rsbuild.entryName
: the name of the current entry.You can directly modify the configuration object and not return anything, or you can return an object as the final configuration.
For example, you can directly modify the built-in meta
configuration object:
In the MPA (Multi-Page Application) scenario, you can return different meta
configurations based on the entry name, thus generating different meta
tags for each page:
Setting the value
of the meta
object to false
and the meta tag will not be generated.
For example to remove the viewport
: