You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By adding the [@rsbuild/plugin-svgr](https://rsbuild.dev/en/plugins/list/plugin-svgr)plugin, Rslib supports invoking [SVGR](https://react-svgr.com/) to convert SVG images into React components for use.
6
6
7
-
## 快速开始
7
+
## Quick Start
8
8
9
-
### 安装插件
9
+
### Install the Plugin
10
10
11
-
你可以通过如下的命令安装插件:
11
+
You can install the plugin using the following command:
In Bundle mode, all usages supported by the [Rsbuild SVGR plugin](https://rsbuild.dev/en/plugins/list/plugin-svgr)are available. The only difference is that when using an SVG file in URL form, Rslib will retain the `import` statement for the static asset in the output according to [Referencing Static Assets](/en/guide/advanced/static-assets).
If the import path does not include the `?react` suffix, the SVG will be treated as a normal static asset, and the `import` statement for the static asset will be retained.
44
+
45
+
`@rsbuild/plugin-svgr` also supports default imports and mixed imports:
44
46
45
47
```js
46
48
importlogoURLfrom'./static/logo.svg';
47
49
48
50
console.log(logoURL);
49
51
```
50
52
51
-
`@rsbuild/plugin-svgr`也支持默认导入和混合导入等用法:
53
+
`@rsbuild/plugin-svgr`also supports default imports and mixed imports:
-Enable default imports by setting [svgrOptions.exportType](https://rsbuild.dev/en/plugins/list/plugin-svgr#svgroptionsexporttype)to`'default'`.
56
+
-Enable mixed imports through the [mixedImport](https://rsbuild.dev/en/plugins/list/plugin-svgr#mixedimport)option to use both default and named imports.
In Bundleless mode, since each file undergoes code transformation independently, the import ways of `?react`and`?url`are not supported. However, the following two usage forms are supported:
`@rsbuild/plugin-svgr`supports named import of `ReactComponent`to use SVGR. You need to set [svgrOptions.exportType](https://rsbuild.dev/en/plugins/list/plugin-svgr#svgroptionsexporttype)to`'named'`.
63
65
64
66
```js
65
67
pluginSvgr({
@@ -75,14 +77,14 @@ import { ReactComponent as Logo } from './logo.svg';
75
77
exportconstApp= () =><Logo />;
76
78
```
77
79
78
-
所有的`.svg`文件都会被转换成 React 组件,此时你可以:
80
+
All`.svg`files will be converted into React components. At this time, you can:
0 commit comments