@@ -64,12 +64,15 @@ function $RefreshSig$() { return RefreshRuntime.createSignatureFunctionForTransf
6464  return  newCode 
6565} 
6666
67- export  function  virtualPreamblePlugin ( { 
68-   isEnabled, 
69- } : { 
67+ export  function  virtualPreamblePlugin ( opts : { 
7068  isEnabled : ( )  =>  boolean 
69+   reactRefreshHost ?: string 
7170} ) : Plugin  { 
7271  const  VIRTUAL_NAME  =  'virtual:@vitejs/plugin-react/preamble' 
72+   let  importSource  =  VIRTUAL_NAME 
73+   if  ( opts . reactRefreshHost )  { 
74+     importSource  =  opts . reactRefreshHost  +  '/@id/__x00__'  +  VIRTUAL_NAME 
75+   } 
7376  return  { 
7477    name : 'vite:react-virtual-preamble' , 
7578    apply : 'serve' , 
@@ -86,7 +89,7 @@ export function virtualPreamblePlugin({
8689      filter : {  id : exactRegex ( '\0'  +  VIRTUAL_NAME )  } , 
8790      handler ( id )  { 
8891        if  ( id  ===  '\0'  +  VIRTUAL_NAME )  { 
89-           if  ( isEnabled ( ) )  { 
92+           if  ( opts . isEnabled ( ) )  { 
9093            // vite dev import analysis can rewrite base 
9194            return  preambleCode . replace ( '__BASE__' ,  '/' ) 
9295          } 
@@ -102,8 +105,11 @@ export function virtualPreamblePlugin({
102105
103106        // this is expected to match `react`, `react-dom`, and `react-dom/client`. 
104107        // they are all optimized to be esm during dev. 
105-         if  ( isEnabled ( )  &&  code . includes ( '__REACT_DEVTOOLS_GLOBAL_HOOK__' ) )  { 
106-           return  `import ${ JSON . stringify ( VIRTUAL_NAME ) }   +  code 
108+         if  ( 
109+           opts . isEnabled ( )  && 
110+           code . includes ( '__REACT_DEVTOOLS_GLOBAL_HOOK__' ) 
111+         )  { 
112+           return  `import ${ JSON . stringify ( importSource ) }   +  code 
107113        } 
108114      } , 
109115    } , 
0 commit comments