Skip to content

Commit 98d29c9

Browse files
committed
docs: add redirect.asset
1 parent 3445f71 commit 98d29c9

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

examples/preact-component-bundle-false/rslib.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import { pluginSass } from '@rsbuild/plugin-sass';
33
import { defineConfig } from '@rslib/core';
44

55
export default defineConfig({
6-
source: {
7-
entry: {
8-
index: ['./src/**'],
9-
},
10-
},
116
lib: [
127
{
138
bundle: false,

website/docs/en/config/lib/redirect.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type StyleRedirect = {
2828
type Redirect = {
2929
js?: JsRedirect;
3030
style?: StyleRedirect;
31+
asset?: boolean;
3132
};
3233
```
3334

@@ -159,3 +160,14 @@ import './index.css'; // expected output
159160
import styles from './index.module.less'; // source code ↓
160161
import styles from './index.module.mjs'; // expected output
161162
```
163+
164+
## redirect.asset
165+
166+
When set to `true`, when importing resource files, the path will be rewritten to the corresponding JavaScript product file.
167+
168+
When set to `false`, the file extension will remain unchanged from the original import path.
169+
170+
```ts
171+
import url from './assets/logo.svg'; // source code ↓
172+
import url from './assets/logo.mjs'; // expected output
173+
```

website/docs/zh/config/lib/redirect.mdx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const defaultRedirect = {
4343
path: true,
4444
extension: true,
4545
},
46+
asset: true,
4647
};
4748
```
4849

@@ -102,7 +103,7 @@ const defaultRedirect = {
102103

103104
当设置为 `true` 时,无论原始扩展名或导入路径中是否指定,文件扩展名都将自动添加到产物文件的重写导入路径中。
104105

105-
当设置为 `false` 时,文件扩展名将保持原始导入路径中的不变(无论是否指定或指定为任意值)。
106+
当设置为 `false` 时,文件扩展名将保持原始导入路径(无论是否指定或指定为任意值)。
106107

107108
## redirect.style
108109

@@ -146,7 +147,7 @@ import styles from '../foo.css'; // './dist/utils/index.js' 预期生成的代
146147

147148
当设置为 `true` 时,导入普通样式文件时,路径将被重写为 `.css` 文件,导入 [CSS Modules](/config/rsbuild/output#outputcssmodules) 时,路径将被重写为到对应的 JavaScript 产物文件。
148149

149-
当设置为 `false` 时,文件扩展名将保持原始导入路径中的不变
150+
当设置为 `false` 时,文件扩展名将保持原始导入路径
150151

151152
- **示例:**
152153

@@ -159,3 +160,14 @@ import './index.css'; // 预期生成的代码
159160
import styles from './index.module.less'; // 源码 ↓
160161
import styles from './index.module.mjs'; // 预期生成的代码
161162
```
163+
164+
## redirect.asset
165+
166+
当设置为 `true` 时,导入资源文件时,路径将被重写到对应的 JavaScript 产物文件。
167+
168+
当设置为 `false` 时,文件扩展名将保持原始导入路径。
169+
170+
```ts
171+
import url from './assets/logo.svg'; // 源码 ↓
172+
import url from './assets/logo.mjs'; // 预期生成的代码
173+
```

0 commit comments

Comments
 (0)