domco

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.

A screenshot of the Cloudflare Build Settings UI. Set the Framework Preset field to "None", set the build command to "npm run build", and the build output directory to ".cloudflare".

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.

A screenshot of the Deno Deploy Project Configuration UI. Set the Framework Preset field to "None", set the build command to "deno run -A npm:vite build", and the entry point to "dist/server/main.js".

Vercel

The Vercel adapter outputs your app to the Build Output API specification.

A screenshot of the Vercel Build and Development Settings UI. Set the Framework Preset field to "Other" and leave all of the other options blank.

Edit this page