Production
srvkit builds your server entry into a production-ready output. The build is handled by your build tool — Vite uses Rolldown, Rsbuild uses Rspack — and srvkit generates a virtual entry that wires your defineServer call to the appropriate runtime.
Running a build
This produces an output file in ./dist/index.js by default.
Entry file
By default, srvkit looks for the entry file at ./src/index.ts, falling back to ./src/index.js if the TypeScript file does not exist. You can override this with the entry option:
Output format
The output format is determined by your package.json. If "type": "module" is set, the output is ESM; otherwise, it is CommonJS.
Build targets
srvkit supports two build targets, controlled by build.target.
server
The default target. Produces a self-starting server — the output calls serve() directly and begins listening when run.
Run the output with your runtime:
handler
Produces an exported handler for serverless platforms like Vercel, AWS Lambda, or Cloudflare Workers. The output does not call serve() — instead, it exports the handler for the platform to invoke.
The output file exports default — a handler that platforms can consume directly.
Bundle modes
Control whether dependencies are included in the output with build.bundle.
external
The default. Keeps all dependencies as import statements. The output requires node_modules to be present at runtime.
standalone
Bundles all dependencies inline. Only Node.js builtins remain external. This produces a self-contained output that can run without node_modules.
Use standalone when deploying to environments where installing dependencies is not practical — Docker containers, single-file deployments, or edge runtimes.
Output configuration
build.outputDir
The directory where the output is written. Defaults to "./dist".
build.outputFile
The filename of the output within the output directory. Defaults to "index.js".
build.minify
Whether to minify the output. Defaults to false.
Server target options
These options only apply when build.target is "server" (the default).
build.host
The hostname the production server binds to. Defaults to "localhost".
build.port
The port the production server listens on. Defaults to 3000.
build.https
HTTPS configuration for the production server. Same shape as the dev.https option — accepts cert, key, and passphrase.
build.publicDir
Path to a directory of static files to serve. Defaults to "./public".
build.copyPublicDir
Whether to copy the public directory into the output directory during build. Defaults to false.
When true, the contents of publicDir are copied into a directory of the same name inside outputDir.