veaury
veaury copied to clipboard
@vitejs/plugin-react can't detect preamble in nuxt application
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 ?
@matthieumasse
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
}
})