Vite
DigitalOcean.Website.Vite deploys a Vite project to App Platform. Deploy builds it on your machine, puts the output in one image, and the App serves the app.
Install
Section titled “Install”The build integration ships separately. It runs only at build time, so a dev dependency is enough:
pnpm add -D https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:3743:41147c9bun add -d https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:3743:41147c9npm install -D https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:3743:41147c9yarn add -D https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:3743:41147c9Declare the site
Section titled “Declare the site”import * as DigitalOcean from "@alchemy.run/digitalocean";import * as Alchemy from "alchemy";import * as Effect from "effect/Effect";
export const Website = DigitalOcean.Website.Vite("Website", { rootDir: "./web" });
export default Alchemy.Stack( "MySite", { providers: DigitalOcean.providers(), state: Alchemy.localState() }, Effect.gen(function* () { const site = yield* Website; return { url: site.url }; }),);rootDir is the directory with the project’s package.json. site.url is the App’s HTTPS address. Deploy needs Docker and the team’s Container Registry, or a registry you declare.
Add environment variables
Section titled “Add environment variables”export const Website = DigitalOcean.Website.Vite("Website", { rootDir: "./web", env: { VITE_GREETING: "Hello from DigitalOcean" },});env is set before the build and on the App, so build-time and run-time code see the same values:
// Vite inlines VITE_* variables at build time.const greeting = import.meta.env.VITE_GREETING;Size the App
Section titled “Size the App”region, instanceSizeSlug and instanceCount are passed to the App. See Websites.
Local dev
Section titled “Local dev”alchemy dev runs Vite’s own dev server with the same env instead of deploying, and site.url is its local address.
Where next
Section titled “Where next”DigitalOcean.Website.Vitereference: every prop.- Websites: what every site on DigitalOcean shares.
- App Platform: the App the site runs on.