File tree 1 file changed +20
-13
lines changed
packages/vite/src/node/plugins
1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change 1
1
import fsp from 'node:fs/promises'
2
+ import type { RolldownPlugin } from 'rolldown'
2
3
import { cleanUrl } from '../../shared/utils'
3
- import type { Plugin } from '../plugin'
4
4
5
5
/**
6
6
* A plugin to provide build load fallback for arbitrary request with queries.
7
7
*/
8
- export function buildLoadFallbackPlugin ( ) : Plugin {
8
+ export function buildLoadFallbackPlugin ( ) : RolldownPlugin {
9
9
return {
10
10
name : 'vite:load-fallback' ,
11
- async load ( id ) {
12
- try {
13
- const cleanedId = cleanUrl ( id )
14
- const content = await fsp . readFile ( cleanedId , 'utf-8' )
15
- this . addWatchFile ( cleanedId )
16
- return content
17
- } catch {
18
- const content = await fsp . readFile ( id , 'utf-8' )
19
- this . addWatchFile ( id )
20
- return content
21
- }
11
+ load : {
12
+ filter : {
13
+ id : {
14
+ exclude : [ / ^ d a t a : / ] ,
15
+ } ,
16
+ } ,
17
+ async handler ( id ) {
18
+ try {
19
+ const cleanedId = cleanUrl ( id )
20
+ const content = await fsp . readFile ( cleanedId , 'utf-8' )
21
+ this . addWatchFile ( cleanedId )
22
+ return content
23
+ } catch {
24
+ const content = await fsp . readFile ( id , 'utf-8' )
25
+ this . addWatchFile ( id )
26
+ return content
27
+ }
28
+ } ,
22
29
} ,
23
30
}
24
31
}
You can’t perform that action at this time.
0 commit comments