Deploy
Run vite build
to build your application into dist/
.
.
└── dist/
├── client/
│ ├── _immutable/
│ └── index.html
└── server/
├── app.js
└── (adapter-entry.js)
By default domco will generate a app.js
module and static assets for your application.
Example
If you are not using an adapter, you can import handler
from the app.js
module and configure your app to use in another environment.
The dist/client/
directory holds client assets. JS and CSS assets with hashed file names will be output to dist/client/_immutable/
, you can serve this path with immutable cache headers. Other assets like HTML files are processed and included in dist/client/
directly.
Here’s an example of how to serve your app using the result of your build using node:http
.
// server.js
// import from build output
import { handler } from "./dist/server/app.js";
// converts web to node
import { nodeListener } from "domco/listener";
import { createServer } from "node:http";
const server = createServer(nodeListener(handler));
server.listen(3000);
Run this module to start your server.
node server.js
Adapters
Add a deployment adapter within your Vite config to output your app to a different target with no additional configuration.
// vite.config
import { domco } from "domco";
// import adapter
import { adapter } from "domco/adapter/vercel";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
domco({
// add to your domco config
adapter: adapter({
// options...
}),
}),
],
});
Cloudflare
The Cloudflare adapter outputs your app to run on Cloudflare Pages.
- Function runs on workerd.
- Outputs public assets to be served on Cloudflare’s CDN.
Deno
The Deno adapter outputs your app to run on Deno Deploy. You do not have to use Deno to build your app to use this adapter.
- Function runs on Deno.
- Static files are served with
@std/http/file-server
.
Vercel
The Vercel adapter outputs your app to the Build Output API specification.
- Function runs on Node.js, Node.js with ISR, or Edge Runtime.
- Outputs public assets to be served on Vercel’s Edge Network.
- Supports on demand Image Optimization when configured in the adapter config. Set the
src
attribute of an image using the/_vercel/image/...
optimized URL format. Indev
andpreview
modes, domco will redirect to the original image.