Skip to content

fix(react-vite): resolve @/* alias — patch JSONC tsconfig.app.json via node

Akram GASSEM requested to merge fix/react-vite-tsconfig-jsonc-alias into main

The scaffold patched tsconfig.app.json with jq, but Vite ships that file as JSONC (// and /* / comments) which jq can't parse — so the patch failed silently and @/ paths only landed in the root tsconfig.json (which has files:[] / no include of src). vite-tsconfig-paths therefore never mapped @/ for source files, and import { x } from '@/...' (e.g. main.tsx → @/router from the tanstack-router addon) failed to resolve: Vite served 500 and the app didn't render.

Strip comments + inject baseUrl/paths with node (always present in a freshly-created Vite project), writing back clean JSON. tsconfig.app.json is the config that include:s src, so vite-tsconfig-paths + tsc both resolve @/ now.

Merge request reports

Loading