fix: vite build does not produce index.html for Tauri release builds #41
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
puregarlic/microclimate#41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Running
deno task build(tsc && vite build) successfully compiles all JS/CSS bundles intobuild/client/assets/but never producesbuild/client/index.html. Sincetauri.conf.jsonpointsfrontendDistat../build/client, the Tauri release build fails to find an entry point.Root Cause
React Router v7's HTML generation — both SPA mode and pre-rendering — lives inside the SSR build's
closeBundlehook, guarded by:deno task buildonly runs a singlevite build(client pass), soisSsrBuildis alwaysfalseand the hook returns early every time. The JS/CSS bundles are emitted but no HTML is ever written.Secondary issue: renderToPipeableStream unavailable in Deno
Once
vite build --ssris added to the task, the SSR pass runs and React Router'shandleSpaModecorrectly generatesindex.html— but only after adding a customapp/entry.server.tsx. The default React Router server entry importsrenderToPipeableStreamfromreact-dom/server. Deno resolvesreact-dom/serverto the browser-flavour module (which exportsrenderToReadableStream, notrenderToPipeableStream), causing a runtime error when the compiled server bundle is loaded:Tertiary issue: build process hangs after cleanup
After
index.htmlis generated, React Router callsfs.rmSync('build/server/', { force: true, recursive: true })to remove the temporary server bundle. The process then hangs indefinitely — likely because the dynamicallyimport()-ed server module keeps the Node.js event loop alive inside Deno's Node compat layer.Solution
Three files changed:
1.
deno.jsonc— add the SSR pass2.
app/entry.server.tsx— new file using Web Streams APIOverrides the default React Router server entry to use
renderToReadableStream(available in the Deno/browser flavour ofreact-dom/server) instead ofrenderToPipeableStream:3.
vite.config.ts— force-exit plugin to unblock the stalled cleanupAfter
index.htmlappears on disk (proof that React Router has finished writing it), wait 500 ms forrmSyncto finish and then callprocess.exit(0):releasebuilds #44