Minimal version of @vavite/connet
and @vavite/expose-vite-dev-server
//
// vite.config.ts
//
import { defineConfig } from "vite";
import { vitePluginSsrMiddleware } from "@hiogawa/vite-plugin-ssr-middleware";
import path from "node:path";
export default defineConfig({
plugins: [
vitePluginSsrMiddleware({
entry: "./server.ts",
preview: path.resolve("./dist/server/index.js"),
}),
],
build: {
outDir: "dist/server",
},
});
//
// server.ts
//
import type { IncomingMessage, ServerResponse } from "node:http";
import type { ViteDevServer } from "vite";
export default function handler(
req: IncomingMessage & { viteDevServer: ViteDevServer },
res: ServerResponse,
next: () => void,
) {
res.end("hello!");
}