Vercel

To deploy a vite-plugin-ssr app to Vercel:

  1. Load dist/server/importBuild.js in your Vercel serverless function. Example: /examples/vercel/vercel/render.js.

    Behind the scenes, Vercel bundles your serverless function and therefore needs to know its entire dependency tree; dist/server/importBuild.js enables Vercel to discover the entire dependency tree of your serverless function.

  2. Define a deploy.sh script. Example: /examples/vercel/vercel/deploy.sh.

  3. Define package.json#scripts['vercel-build'] along with package.json#scripts.build. Example: /examples/vercel/package.json.

    Vercel discards all files generated by package.json#scripts.build. That's why we need to use package.json#scripts['vercel-build']. See Vercel Docs - Custom Build Step for Node.js.

  4. In Vercel's web UI, set the env variable ENABLE_FILE_SYSTEM_API of your Vercel app to 1.

Example:

More infos: