veaury icon indicating copy to clipboard operation
veaury copied to clipboard

@vitejs/plugin-react can't detect preamble in nuxt application

Open matthieumasse opened this issue 7 months ago • 2 comments

Hi,

I can't figure out how to implement React in Nuxt (SPA) using Veaury because i have the following error : "@vitejs/plugin-react can't detect preamble. Something is wrong."

Did anyone faced this problem and solved it ?

Image

matthieumasse avatar May 21 '25 21:05 matthieumasse

@matthieumasse

Image

devilwjp avatar May 26 '25 02:05 devilwjp

I have everything correctly installed. I had to create a nuxt plugin to make it work :

declare global {
  interface Window {
	$RefreshReg$: any;
	$RefreshSig$: any;
	__vite_plugin_react_preamble_installed__: boolean;
  }
}

interface RefreshSig {
  <T>(type: T): T;
}

export default defineNuxtPlugin({
  name: 'react-compatibility',
  setup() {
    // Inform mitt about our event types
    window.$RefreshReg$ = () => {}
    window.$RefreshSig$ = (): RefreshSig => (type) => type;
    window.__vite_plugin_react_preamble_installed__ = true
  }
})

matthieumasse avatar Jun 10 '25 09:06 matthieumasse