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
14 changes: 14 additions & 0 deletions website/docs/en/guide/basic/static-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ console.log(image); // "data:image/png;base64,iVBORw0KGgo..."

For a more detailed introduction to asset inlining, please refer to the [Static Asset Inlining](/guide/optimization/inline-assets) chapter.

## Import as string

Rsbuild supports using the `?raw` query parameter to import the raw content of static assets as a string in JavaScript.

```ts
import rawSvg from './static/logo.svg?raw';

console.log(rawSvg); // The raw content of the SVG file
```

:::tip
Rsbuild >= 1.3.0 supports the `?raw` query parameter.
:::

## Output files

When static assets are imported, they will be output to the dist directory. You can:
Expand Down
14 changes: 14 additions & 0 deletions website/docs/zh/guide/basic/static-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ console.log(image); // "data:image/png;base64,iVBORw0KGgo..."

关于资源内联的更详细介绍,请参考 [静态资源内联](/guide/optimization/inline-assets) 章节。

## 导入为字符串

Rsbuild 支持通过 `?raw` 查询参数引用静态资源的原始内容,并将其作为字符串导入到 JavaScript 中。

```ts
import rawSvg from './static/logo.svg?raw';

console.log(rawSvg); // 输出 SVG 文件的原始内容
```

:::tip
Rsbuild >= 1.3.0 支持 `?raw` 查询参数。
:::

## 构建产物

当静态资源被引用后,会自动被输出到构建产物的目录下,你可以:
Expand Down
Loading