feat: Use Vite for client code splitting

Replaced Bun's client bundler with Vite to fix code splitting issues.
Extracted React and Excalidraw into their own manual chunks to prevent
the monolithic 7MB index.js from blocking rendering. FCP decreased
significantly since browsers can now cache these chunks independently.
This commit is contained in:
ruinivist
2026-05-30 18:02:32 +00:00
parent 7e0ec4b1c4
commit 6044f8da7c
3 changed files with 136 additions and 3 deletions
+3 -2
View File
@@ -5,7 +5,7 @@
"scripts": {
"dev": "bun --hot src/dev-server.tsx",
"build": "rm -rf dist && bun run build:client && bun run build:server",
"build:client": "bun build --target=browser --production --outdir ./dist/public ./src/index.html",
"build:client": "vite build",
"build:server": "mkdir -p ./dist/server && bun build --target=bun --production --outfile ./dist/server/server.js ./src/server.tsx",
"start": "DATABASE_PATH=./data/excalidraw.sqlite bun ./dist/server/server.js",
"test": "bun test",
@@ -20,6 +20,7 @@
"@types/bun": "^1.3.14",
"@types/react": "^19.2.15",
"@types/react-dom": "^19.2.3",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"vite": "^5.0.0"
}
}