html.favicon
- Type:
string | Function - Default: Automatically detects favicon files in the
publicdirectory
Set the favicon icon path for all pages, can be set as:
- a URL.
- an absolute file path.
- a relative path relative to the project root.
After config this option, the favicon will be automatically copied to the dist directory during the compilation, and the corresponding link tag will be added to the HTML.
Rsbuild also provides html.appIcon to set the icon of the web application.
Default value
When html.favicon is not explicitly configured, Rsbuild will automatically look for favicon files in the public directory.
It searches for the following files in order, and uses the first one it finds as the default favicon:
public/favicon.icopublic/favicon.pngpublic/favicon.svg
Example
Set as a relative path:
Set to an absolute path:
Set to a URL:
After recompiling, the following tags are automatically generated in the HTML:
Output path
By default, favicons are output to the root path of the output directory, for example:
./src/assets/icon.pngwill be output to./dist/icon.png../src/assets/favicon.icowill be output to./dist/favicon.ico.
You can customize the output path for favicons using the output.distPath.favicon option:
Function usage
- Type:
When html.favicon is of type Function, the function receives an object as input, with the following properties:
value: the default favicon configuration for Rsbuild.entryName: the name of the current entry.
In the context of MPA (Multi-Page Application), you can return different favicon based on the entry name, thus generating different tags for each page:

