Skip to content

Vite

Source: src/Fly/Website/Vite.ts

Deploy a plain Vite application to Fly: a Service serving the vite build output from a tiny static-file server. For client-only projects — React/Vue/Solid SPAs, index.html multi-page apps — whose entire deployable output is static assets.

The build runs through @alchemy.run/frontend-frameworks/vite with the @alchemy.run/frontend-frameworks/vite/node deploy target — the package must be installed in your project. Your project’s own vite.config.* (plugins included) drives the build.

During alchemy dev the site is Vite’s own dev server (native HMR) and no cloud resources are created — the site’s url is the dev server’s local address. Alchemy.remote() opts back into the full deployment.

Basic Vite SPA

const site = yield* Fly.Website.Vite("Web");

Project in a Subdirectory

const site = yield* Fly.Website.Vite("Web", {
rootDir: "./app",
});

Existing App

const site = yield* Fly.Website.Vite("Web", { app: Site });
const site = yield* Fly.Website.Vite("Docs", {
assets: { notFoundHandling: "404-page" },
});
const site = yield* Fly.Website.Vite("Web", {
domain: "app.example.com",
});
const site = yield* Fly.Website.Vite("Docs", {
vite: { outDir: "build", base: "/docs/" },
});
// `alchemy dev` starts `vite` programmatically: site.url is the local
// dev server (HMR included); no Fly App or Service is created.
const site = yield* Fly.Website.Vite("Web");