Skip to content

Commit d28ab5a

Browse files
authored
docs: add manifest.prefix option documentation (#6682)
1 parent 2589298 commit d28ab5a

File tree

2 files changed

+133
-3
lines changed

2 files changed

+133
-3
lines changed

website/docs/en/config/output/manifest.mdx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,70 @@ const files = [
249249
];
250250
```
251251

252+
### prefix
253+
254+
- **Type:** `boolean`
255+
- **Default:** `true`
256+
257+
Controls whether the generated manifest includes the static asset prefix in file paths. The prefix is taken from [dev.assetPrefix](/config/dev/asset-prefix) and [output.assetPrefix](/config/output/asset-prefix).
258+
259+
When `prefix` is set to `true` (the default), the manifest will include the full asset prefix.
260+
261+
```ts title="rsbuild.config.ts"
262+
export default {
263+
output: {
264+
assetPrefix: 'https://example.com/',
265+
manifest: true,
266+
},
267+
};
268+
```
269+
270+
Example of the generated manifest:
271+
272+
```json title="dist/manifest.json"
273+
{
274+
"allFiles": [
275+
"https://example.com/static/js/index.[hash].js",
276+
"https://example.com/index.html"
277+
],
278+
"entries": {
279+
"index": {
280+
"initial": {
281+
"js": ["https://example.com/static/js/index.[hash].js"]
282+
}
283+
}
284+
}
285+
}
286+
```
287+
288+
If `prefix` is set to `false`, the manifest will keep the file paths relative and no asset prefix will be added.
289+
290+
```ts title="rsbuild.config.ts"
291+
export default {
292+
output: {
293+
assetPrefix: 'https://example.com/',
294+
manifest: {
295+
prefix: false,
296+
},
297+
},
298+
};
299+
```
300+
301+
Example of the generated manifest:
302+
303+
```json title="dist/manifest.json"
304+
{
305+
"allFiles": ["static/js/index.[hash].js", "index.html"],
306+
"entries": {
307+
"index": {
308+
"initial": {
309+
"js": ["static/js/index.[hash].js"]
310+
}
311+
}
312+
}
313+
}
314+
```
315+
252316
### filter
253317

254318
- **Type:**
@@ -353,3 +417,4 @@ export default {
353417
| Version | Changes |
354418
| ------- | ----------------------- |
355419
| v1.6.8 | Added `integrity` field |
420+
| v1.6.12 | Added `prefix` option |

website/docs/zh/config/output/manifest.mdx

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,70 @@ const files = [
249249
];
250250
```
251251

252+
### prefix
253+
254+
- **类型:** `boolean`
255+
- **默认值:** `true`
256+
257+
控制是否在 manifest 中的文件路径前添加静态资源前缀,即 [dev.assetPrefix](/config/dev/asset-prefix)[output.assetPrefix](/config/output/asset-prefix)
258+
259+
`prefix``true`(默认值)时,生成的 manifest 会包含完整的资源前缀。
260+
261+
```ts title="rsbuild.config.ts"
262+
export default {
263+
output: {
264+
assetPrefix: 'https://example.com/',
265+
manifest: true,
266+
},
267+
};
268+
```
269+
270+
生成的 manifest 文件示例:
271+
272+
```json title="dist/manifest.json"
273+
{
274+
"allFiles": [
275+
"https://example.com/static/js/index.[hash].js",
276+
"https://example.com/index.html"
277+
],
278+
"entries": {
279+
"index": {
280+
"initial": {
281+
"js": ["https://example.com/static/js/index.[hash].js"]
282+
}
283+
}
284+
}
285+
}
286+
```
287+
288+
如果将 `prefix` 设置为 `false`,manifest 中的路径将保持相对形式,不会附加静态资源前缀。
289+
290+
```ts title="rsbuild.config.ts"
291+
export default {
292+
output: {
293+
assetPrefix: 'https://example.com/',
294+
manifest: {
295+
prefix: false,
296+
},
297+
},
298+
};
299+
```
300+
301+
生成的 manifest 文件示例:
302+
303+
```json title="dist/manifest.json"
304+
{
305+
"allFiles": ["static/js/index.[hash].js", "index.html"],
306+
"entries": {
307+
"index": {
308+
"initial": {
309+
"js": ["static/js/index.[hash].js"]
310+
}
311+
}
312+
}
313+
}
314+
```
315+
252316
### filter
253317

254318
- **类型:**
@@ -350,6 +414,7 @@ export default {
350414

351415
## 版本历史
352416

353-
| 版本 | 变更内容 |
354-
| ------ | --------------------- |
355-
| v1.6.8 | 新增 `integrity` 字段 |
417+
| 版本 | 变更内容 |
418+
| ------- | --------------------- |
419+
| v1.6.8 | 新增 `integrity` 字段 |
420+
| v1.6.12 | 新增 `prefix` 选项 |

0 commit comments

Comments
 (0)