We can use vite-plugin-vercel
to deploy to Vercel.
vite-plugin-vercel
is in Beta.
We can also manually setup Vercel:
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;
importBuild.js
enables Vercel to discover the entire dependency tree of your serverless function.
Define a deploy.sh
script.
Example: /examples/vercel/vercel/deploy.sh.
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 usepackage.json#scripts['vercel-build']
.
While/after adding your Git repository to Vercel, set the following in Vercel's web UI:
Set FRAMEWORK PRESET
to Other
.
Add a new environment variable named ENABLE_FILE_SYSTEM_API
and set its value to 1
.
We can use Vercel's Incremental Static Regeneration (ISR) by using vite-plugin-vercel which has ISR support.
dist/server/importBuild.js
vercel.json
's config includeFiles
doesn't work for files that are not committed to your Git repository: github.com/vercel/vercel/issues/6478.