File tree Expand file tree Collapse file tree 1 file changed +20
-13
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change 11import fsp from 'node:fs/promises'
2+ import type { RolldownPlugin } from 'rolldown'
23import { cleanUrl } from '../../shared/utils'
3- import type { Plugin } from '../plugin'
44
55/**
66 * A plugin to provide build load fallback for arbitrary request with queries.
77 */
8- export function buildLoadFallbackPlugin ( ) : Plugin {
8+ export function buildLoadFallbackPlugin ( ) : RolldownPlugin {
99 return {
1010 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+ } ,
2229 } ,
2330 }
2431}
You can’t perform that action at this time.
0 commit comments