A Vite + React blog focused on performance, accessibility, and growth.
This repo contains a small blogging site that uses Vite, React (v19), Tailwind CSS, and Sanity CMS for content and image hosting. The aim is to iterate toward the best possible real-user experience (fast LCP, low TBT, and excellent SEO) while enabling growth (analytics, newsletter, social sharing).
- Stabilize repeatable production audits (use a detached static preview server built from
dist). - Fix the Largest Contentful Paint (LCP) — make featured images responsive, use AVIF/WebP fallbacks, and only preload genuine LCP images.
- Shrink vendor JS (split heavy libs, lazy-load when possible, consider replacements for bulky libs).
- Improve image delivery & caching (Sanity srcset helpers, optimized formats, CDN cache rules).
- Add Lighthouse CI on merges to
main(requiresSITE_URLsecret) and use headful audits for stable metrics.
- Vite + React
- Tailwind CSS
- Sanity CMS (images served via Sanity CDN)
- Sentry (error monitoring, optional)
- Google Analytics (GA4 scaffold, optional)
- Lighthouse (local & CI audits)
- Deploy: Vercel (project contains
vercel.json), or any static host
-
Install dependencies:
npm install
-
Copy environment template and set values:
cp .env.example .env.local
- VITE_GA_ID (optional) — Google Analytics
- VITE_SENTRY_DSN (optional) — Sentry
- VITE_SENTRY_ENV (optional)
-
Start dev server:
npm run dev
Note: If PowerShell blocks scripts use Git Bash or cmd.
-
Build production assets:
npm run build
-
Serve the built
diststatically for production-like audits:node scripts/serve-dist.js # default port 5173
- Start it in a detached terminal so it persists between audit runs.
-
Dev server (quick checks) — contains dev-only artifacts like
@vite/client; use only for development checks.npx lighthouse http://localhost:5173 --output=json --output-path=./reports/lighthouse-local.json --chrome-flags='--headless=false'
-
Production preview (accurate metrics) — important: use the static
distpreviewnpx lighthouse http://localhost:5173 --output=json --output-path=./reports/lighthouse-prod.json --chrome-flags='--headless=false'
Notes:
- Use headful runs (
--headless=false) for deterministic LCP and filmstrip artifacts. - If ChromeLauncher reports permission or interstitial errors, re-run after ensuring the preview server is reachable.
- Add
SITE_URLas a repository secret and enable the provided workflow (see.github/workflows/lighthouse.yml) to run on pushes tomainand PR merges.
- Sentry: set
VITE_SENTRY_DSNfor runtime error capture (lazy init is used to avoid startup cost). AddVITE_COMMIT_SHAto link releases. - GA4: set
VITE_GA_ID; GA events are triggered for page views and newsletter signups.
- SEO front matter is available in Sanity (
metaTitle,metaDescription,ogImage,canonical). - Sitemap &
robots.txtplaceholders are included — updateSITE_URLand paths if you change routing.
- Responsive featured image
srcset+sizes(usesrcSetFor()helper insrc/lib/sanityImage.js). - Ensure LCP candidate images are preloaded only when necessary.
- Add AVIF/WebP fallbacks where supported by Sanity image builder.
- Reduce initial JS: refine
manualChunksinvite.config.js, lazy-load syntax highlighters and heavy libs. - Replace or inline small icon libs (we already replaced react-icons with inline SVGs in
Footer.jsx).
- Branches:
mainfor production,feat/*for features,fix/*for fixes. - Commit messages: use Conventional Commits (e.g.,
feat: add newsletter form,fix: tidy build output). - PR checklist:
- Lint & format ✅
- Build succeeds (
npm run build) ✅ - If changing public assets, run a production preview + Lighthouse check ✅
- We expect to deploy to Vercel (see
vercel.json). Connect the GitHub repo, set build env vars (VITE_GA_ID,VITE_SENTRY_DSN,SITE_URL) in the Vercel dashboard, and enable protected production deploys.
- Stabilize production audits and re-run Lighthouse (I can do this on request).
- Implement responsive/optimized LCP image delivery (change
SinglePost.jsx/HomePage.jsx). - Reduce vendor JS (further manualChunks + lazy imports).
- Add Lighthouse CI and confirm
SITE_URLsecret. - Review image CDN caching & content-type delivery for AVIF/WebP.
- npm run dev # local dev server
- npm run build # production build
- node scripts/serve-dist.js # static production preview
- npx lighthouse # run Lighthouse locally (headful recommended)
See repository license