Audit the Vite configuration for this React 19 + Express SPA project. Check for correctness, performance, and optimization opportunities.
Target: $ARGUMENTS (default: full audit)
Pre-flight
- Read
vite.config.ts,package.json,tsconfig.json, andindex.html. - Glob for
src/**/*.{ts,tsx}barrel files (index.tsthat re-export). - Check installed Vite version and plugin versions in
node_modules.
Audit Checklist
1. CORE CONFIG
- Uses
defineConfigwrapper (enables IDE autocomplete and type safety) - Config function receives
{ mode, command }for conditional logic -
loadEnvused correctly if accessing env vars in config (notprocess.envdirectly for.envfiles) - No hardcoded secrets in
define— only public/build-time values -
definevalues useJSON.stringify()for string replacements -
process.env.*replacements don't leak server secrets to client bundle
2. PLUGINS
-
@vitejs/plugin-reactpresent for React JSX transform - Plugin order is correct (React before Tailwind for proper HMR)
-
@tailwindcss/viteused instead of PostCSS plugin (Tailwind v4 best practice) - No duplicate plugins (e.g., both PostCSS autoprefixer AND Tailwind Vite plugin)
- No unnecessary plugins that slow dev startup
- Consider
vite-plugin-compressionfor pre-compressed assets if not using Vercel (Vercel auto-compresses)
3. RESOLVE & ALIASES
- Path aliases match
tsconfig.jsonpathsconfiguration exactly - Alias target uses
path.resolvewith__dirnameorimport.meta.dirname(not relative strings) -
resolve.extensionsnot unnecessarily expanded (defaults are fine:.mjs,.js,.mts,.ts,.jsx,.tsx,.json) - No barrel file re-exports causing unnecessary module loading — prefer direct imports
- TypeScript
moduleResolution: "bundler"set (optimal for Vite)
4. BUILD OPTIMIZATION
-
build.targetappropriate for audience (default'baseline-widely-available'is good for modern apps) -
build.outDirmatches VerceloutputDirectoryconfig -
build.sourcemapconfigured:'hidden'for production with Sentry (uploads maps, doesn't expose to users)truefor development/stagingfalseonly if no error tracking
-
build.minifyuses default'oxc'(30-90x faster than terser, near-identical compression) -
build.cssMinifynot set to less optimal value than default -
build.reportCompressedSizeset tofalsefor faster builds on large projects -
build.chunkSizeWarningLimitat reasonable value (default 500 KB) - Code splitting configured via
build.rollupOptions.output.manualChunksif needed:- Vendor chunk for
react,react-dom,react-router-dom - Separate chunk for heavy deps (
openai,@google/genai,motion)
- Vendor chunk for
-
build.cssCodeSplit: true(default) for async chunk CSS isolation
5. DEV SERVER
-
server.portset explicitly for consistent dev URL -
server.hostset to'0.0.0.0'ortrueif network access needed (mobile testing) -
server.proxycorrectly forwards/apito Express backend - Proxy uses
changeOrigin: truefor correctHostheader -
server.warmupconfigured for frequently-used files (speeds up initial page load):server: { warmup: { clientFiles: ['./src/App.tsx', './src/main.tsx'] } } - HMR not unnecessarily disabled
-
server.fs.allownot overly permissive
6. ENVIRONMENT VARIABLES
- Only
VITE_*prefixed vars are exposed to client (by design) - No server secrets passed via
defineto client bundle -
loadEnvcalled with correct directory (.orprocess.cwd()) -
envPrefixnot changed from default'VITE_'without good reason -
GEMINI_API_KEYindefine— verify this doesn't leak to client bundle- If used server-side only, remove from
defineand access via Express - If used client-side, prefix as
VITE_GEMINI_API_KEY
- If used server-side only, remove from
7. CSS & STYLING
- Tailwind CSS v4 using
@tailwindcss/viteplugin (not PostCSS) - No redundant
autoprefixerin PostCSS config (Tailwind v4 handles this) - No
postcss.config.jsconflicting with Vite plugin setup - CSS imports use native CSS when possible (avoid Sass/Less unless needed)
- No unused CSS preprocessor dependencies in
package.json
8. TYPESCRIPT INTEGRATION
-
tsconfig.jsontargetmatches or is compatible with Vite'sbuild.target -
moduleResolution: "bundler"(optimal for Vite) -
isolatedModules: true(required for Vite's esbuild transform) -
allowImportingTsExtensions: trueif using.ts/.tsxin imports -
noEmit: true(Vite handles emit, TS only type-checks) -
jsx: "react-jsx"for React 19 automatic JSX transform -
libincludes"DOM"and"DOM.Iterable"for browser APIs -
skipLibCheck: truefor faster type checking (standard practice)
9. DEPENDENCY OPTIMIZATION
- Heavy dependencies considered for
optimizeDeps.includeto speed up dev cold start:react,react-dom,react-router-domopenai,@google/genai(large packages)
- Problematic CJS packages in
optimizeDeps.includeif causing issues -
vitenot duplicated in bothdependenciesANDdevDependencies -
autoprefixerindevDependenciesis redundant with Tailwind v4 — can be removed
Output Format
## Vite Audit Report
### Score: X/9 dimensions passing
### Critical Issues
1. [DIMENSION] — [severity: CRITICAL/HIGH/MEDIUM/LOW] — description
Current: `current config`
Fix: specific fix with code
### Warnings
1. [DIMENSION] — description
Recommendation: what to change
### Optimizations
1. [DIMENSION] — description
Benefit: expected improvement
### Passing
- [DIMENSION] — what's configured correctly
### Recommended vite.config.ts
(Only if changes needed — show the complete corrected file)