Skip to content

Latest commit

 

History

History

vite-plugin-ssr-middleware

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

vite-plugin-ssr-middleware

Minimal version of @vavite/connet and @vavite/expose-vite-dev-server

example

//
// 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!");
}