79329591

Date: 2025-01-04 21:07:19
Score: 0.5
Natty:
Report link

Fixed after I added this script in the head tag of my cshtml file:

<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>

I was getting the "Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong." Vite server error since I wasn't importing the refresh runtime that the Vite server provides to allow HMR.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Simon Markus