Quantcast
Channel: User totymedli - Stack Overflow
Viewing all articles
Browse latest Browse all 54

Answer by totymedli for Vitest Error : React refresh preamble was not loaded. Something is wrong

$
0
0

tl;dr

If you are importing the Vite generated bundle as a .js file instead of via an HTML entry file, then you should follow the backend integration guide of the official docs.

Add necessary scripts

You will need @vite/client and your bundle, in this case main.js:

<script type="module" src="http://localhost:5173/@vite/client"></script><script type="module" src="http://localhost:5173/main.js"></script>

Add the code that modifies the HTML:

<script type="module">  import RefreshRuntime from 'http://localhost:5173/@react-refresh'  RefreshRuntime.injectIntoGlobalHook(window)  window.$RefreshReg$ = () => {}  window.$RefreshSig$ = () => (type) => type  window.__vite_plugin_react_preamble_installed__ = true</script>

Viewing all articles
Browse latest Browse all 54

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>