Repository navigation
Description
What happened
In a TanStack Start project, cf build --mode <name> and cf dev --mode <name> both fail before anything runs:
$ cf build --mode production
┌ Error
│ The detected command `bunx vite build` does not currently support `--mode`.
└
$ cf dev --mode production
┌ Error
│ The detected command `bunx vite dev` does not currently support `--mode`.
└
(With npm the command is shown as npx vite build.)
The detected command is plain vite build / vite dev, and Vite accepts --mode. The same project without @tanstack/react-start installed works: cf build --mode production delegates to vite build "--mode" "production" and succeeds.
Minimal reproduction
mkdir cf-mode-repro && cd cf-mode-repro
cat > package.json <<'JSON'
{ "name": "cf-mode-repro", "private": true, "type": "module",
"devDependencies": { "vite": "8.3.6", "@cloudflare/vite-plugin": "2.0.0-beta.v.12", "cf": "1.0.0-beta.28" } }
JSON
cat > vite.config.ts <<'TS'
import { defineConfig } from "vite";
import { cloudflare } from "@cloudflare/vite-plugin";
export default defineConfig({ plugins: [cloudflare()] });
TS
mkdir src && echo 'export default { fetch() { return new Response("ok") } }' > src/index.ts
cat > cloudflare.config.ts <<'TS'
import { defineConfig } from "cf/config";
export default defineConfig({ worker: { name: "cf-mode-repro", entrypoint: "./src/index.ts", compatibilityDate: "2026-11-01" } });
TS
bun install
cf build --mode production # works: "Delegating to bunx vite build "--mode" "production""
bun add -d @tanstack/[email protected] react@19 react-dom@19
cf build --mode production # fails: "does not currently support `--mode`"
cf dev --mode production # fails the same way
Likely cause
In the bundled autoconfig, the Vite and Astro framework classes set supportsMode = true, but the TanStack Start class extends the base Framework class (supportsMode = false). Its configuration still reports buildTool: "vite", and the build and dev commands are <pm> vite build / <pm> vite dev. cf build then throws on if (buildCommand && mode && !framework.supportsMode).
Setting supportsMode = true for TanStack Start (or deriving it from buildTool === "vite") should fix it.
Why it matters
defineConfig(({ mode }) => …) can't branch on mode for TanStack Start projects through cf. That rules out a staging or preview Worker. Our workaround is to call vite build --mode <name> directly and skip cf build.
Environment
cf1.0.0-beta.28,@cloudflare/vite-plugin2.0.0-beta.v.12,@tanstack/react-start1.169.4, Vite 8.3.6- macOS (arm64), Node 26.13, Bun 1.4.4. Also reproduced with npm (no lockfile, monorepo workspace).
Related
#45 covers the same error for Nuxt and Next.js, which don't build through Vite. This one is narrower: TanStack Start already builds through vite, so only the supportsMode flag is missing.
Activity