rwsdk
Version:
Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime
12 lines (11 loc) • 523 B
JavaScript
import MagicString from "magic-string";
import { virtualPlugin } from "./virtualPlugin.mjs";
export const vitePreamblePlugin = () => virtualPlugin("vite-preamble", async () => {
const s = new MagicString(`
import RefreshRuntime from "/@react-refresh"; RefreshRuntime.injectIntoGlobalHook(window); window.$RefreshReg$ = () => {}; window.$RefreshSig$ = () => (type) => type; window.__vite_plugin_react_preamble_installed__ = true;
`);
return {
code: s.toString(),
map: s.generateMap(),
};
});