@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

main
ts 23 lines 803 Bytes
Raw
1 // Mirrors `@cloudflare/vite-plugin`'s `playground/hot-channel/vite.config.ts`:
2 // the dev server and the Worker exchange custom events over the Worker
3 // environment's hot channel.
4 import type { Plugin, ViteDevServer } from "vite";
5
6 const hotChannelPlugin: Plugin = {
7 name: "test-plugin",
8 configureServer(server: ViteDevServer) {
9 const worker = server.environments.ssr;
10 if (!worker) throw new Error("'ssr' environment not found");
11 return () => {
12 server.middlewares.use((_request, _response, next) => {
13 worker.hot.on("worker-event", (payload) => {
14 worker.hot.send("worker-event-received", payload);
15 });
16 worker.hot.send("server-event", "server-event-data");
17 next();
18 });
19 };
20 },
21 };
22
23 export default { plugins: [hotChannelPlugin] };