@@ -35,7 +35,7 @@ bun add @rsbuild/plugin-assets-retry -D
35
35
你可以在 ` rsbuild.config.ts ` 文件中注册插件:
36
36
37
37
``` ts
38
- import { pluginAssetsRetry } from " @rsbuild/plugin-assets-retry" ;
38
+ import { pluginAssetsRetry } from ' @rsbuild/plugin-assets-retry' ;
39
39
40
40
export default {
41
41
plugins: [pluginAssetsRetry ()],
@@ -62,7 +62,7 @@ type AssetsRetryOptions = {
62
62
domain? : string [];
63
63
max? : number ;
64
64
test? : string | ((url : string ) => boolean );
65
- crossOrigin? : boolean | " anonymous" | " use-credentials" ;
65
+ crossOrigin? : boolean | ' anonymous' | ' use-credentials' ;
66
66
inlineScript? : boolean ;
67
67
delay? : number | ((context : AssetsRetryHookContext ) => number );
68
68
onRetry? : (context : AssetsRetryHookContext ) => void ;
@@ -75,10 +75,10 @@ type AssetsRetryOptions = {
75
75
76
76
``` ts
77
77
const defaultOptions = {
78
- type: [" script" , " link" , " img" ],
78
+ type: [' script' , ' link' , ' img' ],
79
79
domain: [],
80
80
max: 3 ,
81
- test: " " ,
81
+ test: ' ' ,
82
82
crossOrigin: false ,
83
83
delay: 0 ,
84
84
onRetry : () => {},
@@ -101,11 +101,11 @@ const defaultOptions = {
101
101
defineConfig ({
102
102
plugins: [
103
103
pluginAssetsRetry ({
104
- domain: [" cdn1.com" , " cdn2.com" , " cdn3.com" ],
105
- })
104
+ domain: [' cdn1.com' , ' cdn2.com' , ' cdn3.com' ],
105
+ }),
106
106
],
107
107
output: {
108
- assetPrefix: " https://cdn1.com" , // 或者 "//cdn1.com"
108
+ assetPrefix: ' https://cdn1.com' , // 或者 "//cdn1.com"
109
109
},
110
110
});
111
111
```
@@ -125,7 +125,7 @@ defineConfig({
125
125
126
126
``` js
127
127
pluginAssetsRetry ({
128
- type: [" script" , " link" ],
128
+ type: [' script' , ' link' ],
129
129
});
130
130
```
131
131
@@ -180,7 +180,7 @@ pluginAssetsRetry({
180
180
pluginAssetsRetry ({
181
181
onRetry : ({ times, domain, url, tagName, isAsyncChunk }) => {
182
182
console .log (
183
- ` Retry ${ times} times, domain: ${ domain} , url: ${ url} , tagName: ${ tagName} , isAsyncChunk: ${ isAsyncChunk} `
183
+ ` Retry ${ times} times, domain: ${ domain} , url: ${ url} , tagName: ${ tagName} , isAsyncChunk: ${ isAsyncChunk} ` ,
184
184
);
185
185
},
186
186
});
@@ -196,7 +196,7 @@ pluginAssetsRetry({
196
196
pluginAssetsRetry ({
197
197
onSuccess : ({ times, domain, url, tagName, isAsyncChunk }) => {
198
198
console .log (
199
- ` Retry ${ times} times, domain: ${ domain} , url: ${ url} , tagName: ${ tagName} , isAsyncChunk: ${ isAsyncChunk} `
199
+ ` Retry ${ times} times, domain: ${ domain} , url: ${ url} , tagName: ${ tagName} , isAsyncChunk: ${ isAsyncChunk} ` ,
200
200
);
201
201
},
202
202
});
@@ -212,7 +212,7 @@ pluginAssetsRetry({
212
212
pluginAssetsRetry ({
213
213
onFail : ({ times, domain, url, tagName, isAsyncChunk }) => {
214
214
console .log (
215
- ` Retry ${ times} times, domain: ${ domain} , url: ${ url} , tagName: ${ tagName} , isAsyncChunk: ${ isAsyncChunk} `
215
+ ` Retry ${ times} times, domain: ${ domain} , url: ${ url} , tagName: ${ tagName} , isAsyncChunk: ${ isAsyncChunk} ` ,
216
216
);
217
217
},
218
218
});
@@ -319,7 +319,7 @@ pluginAssetsRetry({
319
319
``` js
320
320
// 通过次数来计算延迟时间
321
321
pluginAssetsRetry ({
322
- delay : ( ctx ) => (ctx .times + 1 ) * 1000 ,
322
+ delay : ctx => (ctx .times + 1 ) * 1000 ,
323
323
});
324
324
```
325
325
@@ -334,12 +334,12 @@ pluginAssetsRetry({
334
334
以下是一个错误示例:
335
335
336
336
``` js
337
- import { someMethod } from " utils" ;
337
+ import { someMethod } from ' utils' ;
338
338
339
339
pluginAssetsRetry ({
340
340
onRetry () {
341
341
// 错误用法,包含了敏感信息
342
- const privateToken = " a-private-token" ;
342
+ const privateToken = ' a-private-token' ;
343
343
344
344
// 错误用法,使用了外部的方法
345
345
someMethod (privateToken);
0 commit comments