Repository navigation
fix(deploy): upload dist/client for a Vite app built with void - #907
Brooooooklyn wants to merge 1 commit into
Conversation
A Vite app that depends on `void` builds with voidPlugin(), which writes browser files to dist/client and the server bundle, its source map and wrangler.json to dist/ssr. With no backend files, detectPreset step 4 picked `dist` as the static output, so `void deploy` published the server files and `/` returned 404 (index.html sat at /client/index.html). Pick dist/client in that case. A plain Vite app keeps `dist`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 154d3ca016
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * without an `index.html`. | ||
| */ | ||
| function viteSpaOutputDir(pkg: Record<string, unknown>): string { | ||
| return hasPackageDependency(pkg, 'void') ? 'dist/client' : 'dist'; |
There was a problem hiding this comment.
Distinguish CLI installation from use of the Vite plugin
For a plain Vite SPA that installs void to use its deployment CLI but does not enable voidPlugin(), this changes the upload directory to dist/client even though the build still produces dist/index.html. Both deploy-managed-static.ts and deploy-cloudflare-static.ts reject the nonexistent output directory after a successful build, so previously working static deployments now fail. A void dependency does not establish that its Vite plugin runs; determine whether the split build layout is actually used before selecting dist/client, while retaining dist for CLI-only installations.
Useful? React with 👍 / 👎.
How this was found
We tested the security-audits work (PR #886) end to end on a live self-hosted Void platform. One test app was a Vite app that uses
voidPlugin()and has no backend. Deploying it broke the site and made server files public. The bug is not part of the security-audits feature, and the same code is onmain, so it gets its own PR.Repro
package.jsonhasvite-plusandvoid.vite.config.tsusesplugins: [voidPlugin()].index.htmlandmain.js. Noroutes/,pages/, or other backend folders.void deployto a Void platform. The CLI prints "Static SPA deploy"./index.html/client/index.html/ssr/index.js.mapsourcesContent)/ssr/wrangler.jsonUploaded files on main:
client/index.html,client/assets/*,client/.vite/manifest.json,ssr/index.js,ssr/index.js.map,ssr/wrangler.json,ssr/.vite/manifest.json.Side effect: the server bundle has a new random build key on every build (
packages/void/src/router/compile.ts:881-883), so a redeploy of unchanged code uploaded a changedssr/index.js.mapand made a new deployment (and, with security audits on, a new scan) each time.Root cause
packages/void/src/cli/preset.ts:277-285(step 4) always useddist. That is right for plain Vite, which writesdist/index.html. ButvoidPlugin()splits the build:So the whole
dist/went up, and/had noindex.html.The same step is used by the managed platform path (
cli/deploy.ts), the native Cloudflare static path (resolveCloudflareStaticPresetincli/deploy-cloudflare-static.ts), and by configuredinference.appType: "spa" | "static"withoutoutputDir(resolveStaticDeployPresetincli/deploy-helpers.ts). All three get the fix.Fix
In step 4, when the package depends on
void, usedist/client. Plain Vite apps keepdist.void initaddsvoidPlugin()to Vite apps, so avoiddependency means the build has the split layout. App type staysspa, same as before; only the folder changes.The docs for
inference.outputDirnow say the default isdist/clientfor projects that depend onvoid.Tests
packages/void/test/unit/preset.test.tsuploads only dist/client for a Vite app built with void and no backend: vite-plus + void, onlyindex.html+main.js->dist/client,spa.uses dist/client for a configured static app built with void:inference.appType: "spa"with nooutputDir->dist/client.dist) and pass with the fix. The plain Vite and Vite+ tests still expectdist.vp run test: all groups pass except one timeout inplatform/packages/api/test/integration/admin-dashboard.test.ts("keeps runtime-log client fields when navigating away and back", 5 s, dashboard UI, not touched here). It passes when run alone.vp fmt --check,vp lint, and thevoidpackage typecheck pass. In a fresh worktree,vp checkalso reports missingplayground/*/.void/tsconfig.jsonfiles, which are generated by a playground build and are unrelated.🤖 Generated with Claude Code