Skip to content

Commit c3025ea

Browse files
authored
docs: add distPath.favicon option (#5747)
1 parent 160a5bb commit c3025ea

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

website/docs/en/config/html/favicon.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ After recompiling, the following tags are automatically generated in the HTML:
5757
<link rel="icon" href="/favicon.ico" />
5858
```
5959

60+
## Output path
61+
62+
By default, favicons are output to the root path of the output directory, for example:
63+
64+
- `./src/assets/icon.png` will be output to `./dist/icon.png`.
65+
- `./src/assets/favicon.ico` will be output to `./dist/favicon.ico`.
66+
67+
You can customize the output path for favicons using the [output.distPath.favicon](/config/output/dist-path) option:
68+
69+
```ts title="rsbuild.config.ts"
70+
export default {
71+
output: {
72+
distPath: {
73+
// Output favicon to "./dist/static/favicon/" directory
74+
favicon: 'static/favicon',
75+
},
76+
},
77+
};
78+
```
79+
6080
## Function usage
6181

6282
- **Type:**

website/docs/en/config/output/dist-path.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
type DistPathConfig = {
77
root?: string;
88
html?: string;
9+
favicon?: string;
910
js?: string;
1011
jsAsync?: string;
1112
css?: string;
@@ -25,6 +26,7 @@ type DistPathConfig = {
2526
const defaultDistPath = {
2627
root: 'dist',
2728
html: './',
29+
favicon: './',
2830
js: output.target === 'node' ? '' : 'static/js',
2931
jsAsync: output.target === 'node' ? '' : 'static/js/async',
3032
css: 'static/css',
@@ -50,6 +52,7 @@ Here are the details of each `output.distPath` option:
5052

5153
- `root`: The root directory of all output files.
5254
- `html`: The output directory of HTML files.
55+
- `favicon`: The output directory of favicon files.
5356
- `js`: The output directory of JavaScript files.
5457
- `jsAsync`: The output directory of async JavaScript files, which by default will be output to the `async` subdirectory of `distPath.js`.
5558
- `css`: The output directory of CSS style files.

website/docs/zh/config/html/favicon.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ export default {
5757
<link rel="icon" href="/favicon.ico" />
5858
```
5959

60+
## 输出路径
61+
62+
默认情况下,favicon 文件会输出到构建产物目录的根路径下,比如:
63+
64+
- `./src/assets/icon.png` 会输出到 `./dist/icon.png`
65+
- `./src/assets/favicon.ico` 会输出到 `./dist/favicon.ico`
66+
67+
你可以通过 [output.distPath.favicon](/config/output/dist-path) 选项来自定义 favicon 的输出路径:
68+
69+
```ts title="rsbuild.config.ts"
70+
export default {
71+
output: {
72+
distPath: {
73+
// 将 favicon 输出到 "./dist/static/favicon/" 目录
74+
favicon: 'static/favicon',
75+
},
76+
},
77+
};
78+
```
79+
6080
## 函数用法
6181

6282
- **类型:**

website/docs/zh/config/output/dist-path.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
type DistPathConfig = {
77
root?: string;
88
html?: string;
9+
favicon?: string;
910
js?: string;
1011
jsAsync?: string;
1112
css?: string;
@@ -25,6 +26,7 @@ type DistPathConfig = {
2526
const defaultDistPath = {
2627
root: 'dist',
2728
html: './',
29+
favicon: './',
2830
js: output.target === 'node' ? '' : 'static/js',
2931
jsAsync: output.target === 'node' ? '' : 'static/js/async',
3032
css: 'static/css',
@@ -50,6 +52,7 @@ const defaultDistPath = {
5052

5153
- `root`: 所有构建产物输出的根目录。
5254
- `html`:HTML 文件的输出目录。
55+
- `favicon`:favicon 文件的输出目录。
5356
- `js`:JavaScript 文件的输出目录。
5457
- `jsAsync`:异步 JavaScript 文件的输出目录,默认会输出到 `distPath.js``async` 子目录。
5558
- `css`:CSS 文件的输出目录。

0 commit comments

Comments
 (0)