FabricFabricHarness
Reference

Vite integration

Compose Vite 8 with Harness development and portable build targets without replacing fh dev or fh build.

@fabric-harness/vite is an optional composition layer. It does not scan for implicit agent functions or replace Harness's explicit defineAgent() / createAgent() identities. The same workspace discovery and target registry continue to power fh dev, fh build, and Vite.

Install

pnpm add -D @fabric-harness/vite vite
vite.config.ts
import { defineConfig } from 'vite';
import { fabricHarness } from '@fabric-harness/vite';

export default defineConfig({
  plugins: [fabricHarness({ target: 'node' })],
});

During vite dev, Harness HTTP, SSE, and WebSocket route prefixes are proxied through the Vite server. The backing Harness server binds an ephemeral loopback port and is drained when Vite closes. Shell-exported environment values retain precedence; use Vite's normal environment loading for the front-end and Harness's documented runtime secret resolvers for privileged credentials.

During vite build, the plugin invokes the same portable build registry as:

fh build --target node

The Harness artifact remains under .fabricharness/build/<target>/; Vite owns its own output. Set standalone: true for a headless workspace with no HTML or application entry:

fabricHarness({ target: 'node', standalone: true })

Cloudflare

Compose the official Cloudflare plugin as a sibling and keep Harness first:

vite.config.ts
import { cloudflare } from '@cloudflare/vite-plugin';
import { defineConfig } from 'vite';
import {
  fabricHarness,
  fabricHarnessWorkerConfig,
} from '@fabric-harness/vite';

export default defineConfig({
  plugins: [
    fabricHarness({ target: 'cloudflare', standalone: true }),
    cloudflare({ config: fabricHarnessWorkerConfig() }),
  ],
});

The customizer contributes only the generated Worker entry and nodejs_compat. Authored Wrangler bindings, Durable Object migrations, deployment names, environments, and observability settings pass through unchanged. Calling the customizer before fabricHarness(), reversing plugin order, or using a non-Cloudflare Harness target fails with an actionable configuration error.

Choosing a path

NeedCommand
One-shot, no transportfh run <job>
Harness-only developmentfh dev
Existing Vite applicationvite dev with fabricHarness()
Portable deployment artifactfh build --target <target> or the equivalent Vite composition

Harness keeps fh dev and fh build because Vite is not available on every supported deployment or authoring surface. The integration is optional for local projects and never makes Vite a core SDK dependency.