Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions website/docs/en/config/output/manifest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,32 @@ api.onAfterBuild(({ environments }) => {

> See [Environment API - manifest](/api/javascript-api/environment-api#manifest) for more details.

## SRI

When the [`security.sri`](/config/security/sri) option is enabled, the manifest file includes an `integrity` field that stores the SRI hash for assets that support Subresource Integrity, such as JavaScript and CSS files.

```ts title="rsbuild.config.ts"
export default {
security: {
sri: {
enable: 'auto',
},
},
output: {
manifest: true,
},
};
```

```json title="dist/manifest.json"
{
"allFiles": ["/static/js/index.[hash].js", "/index.html"],
"integrity": {
"/static/js/index.[hash].js": "sha384-[sri-hash]"
}
}
```

## Options

`output.manifest` can be an object, here are all the options:
Expand Down Expand Up @@ -321,3 +347,9 @@ export default {
},
};
```

## Version history

| Version | Changes |
| ------- | ----------------------- |
| v1.6.8 | Added `integrity` field |
2 changes: 2 additions & 0 deletions website/docs/en/config/security/sri.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ After enabling `security.sri`, the `<script>` and `<link>` tags generated by Rsb
/>
```

In addition, the [manifest file](/config/output/manifest#sri) generated by Rsbuild will also include an `integrity` field.

## Note

The `security.sri` in Rsbuild will only apply to the tags generated by Rspack and Rsbuild and will not apply to:
Expand Down
32 changes: 32 additions & 0 deletions website/docs/zh/config/output/manifest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,32 @@ api.onAfterBuild(({ environments }) => {

> 参考 [Environment API - manifest](/api/javascript-api/environment-api#manifest) 了解更多。

## SRI

当启用 [security.sri](/config/security/sri) 选项后,manifest 文件会包含 `integrity` 字段,用于存储支持 SRI 的资源(例如 JavaScript 和 CSS 文件)的哈希值。

```ts title="rsbuild.config.ts"
export default {
security: {
sri: {
enable: 'auto',
},
},
output: {
manifest: true,
},
};
```

```json title="dist/manifest.json"
{
"allFiles": ["/static/js/index.[hash].js", "/index.html"],
"integrity": {
"/static/js/index.[hash].js": "sha384-[sri-hash]"
}
}
```

## 选项

`output.manifest` 可以是一个对象,以下是所有可选项:
Expand Down Expand Up @@ -321,3 +347,9 @@ export default {
},
};
```

## 版本历史

| 版本 | 变更内容 |
| ------ | --------------------- |
| v1.6.8 | 新增 `integrity` 字段 |
2 changes: 2 additions & 0 deletions website/docs/zh/config/security/sri.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export default {
/>
```

此外,Rsbuild 生成的 [manifest 文件](/config/output/manifest#sri) 也会包含 `integrity` 字段。

## 注意

Rsbuild 的 `security.sri` 仅会作用于 Rspack 和 Rsbuild 生成的标签,不会作用于:
Expand Down
Loading