A React + TypeScript project bootstrapped with Vite.
- React 18
- TypeScript
- Vite (dev server & build)
- Node.js ≥ 18
- Package manager: Yarn (via Corepack) or npm
If yarn isn't available:
corepack enable
corepack prepare yarn@stable --activate# with yarn
yarn
# or with npm
npm install# yarn
yarn dev
# npm
npm run devOpen the printed URL (usually http://localhost:5173).
# yarn
yarn build
# npm
npm run buildThe production files will be in the dist/ folder.
# yarn
yarn preview
# npm
npm run previewThis serves the dist/ output locally to verify the build.
{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}gdsc_nus/
index.html
package.json
tsconfig.json
vite.config.ts
src/
main.tsx
App.tsx
assets/
Vite exposes variables prefixed with VITE_.
- Create a
.envfile in the project root:
VITE_API_BASE_URL=https://api.example.com- Use in code:
import.meta.env.VITE_API_BASE_URL
- Port already in use:
yarn dev --port 5174(ornpm run dev -- --port 5174) - Install errors on macOS (Apple Silicon): ensure Homebrew/Node paths are set and Node ≥ 18.
- Blank page after build (when hosting at a subpath): set
baseinvite.config.tsto your subpath.
The dist/ folder is static. You can deploy it to Netlify, Vercel, GitHub Pages, Cloudflare Pages, or any static host.