yarn
yarn start
This will start a local server listening for http requests on port 3000.
It will also ask your browser to open a tab to http://localhost:3000/
Any type-check and linting errors will appear in the browser and in the terminal output as you browse.
Run the default build task in vscode using ctrl-shift-B (or mac: Cmd-shift-B) This will run first type-checking and if that passes will then run eslint. VSCode's problems list will be populated with errors from the first of those tasks to fail.
This is configured in .vscode/tasks.json
If you find lint is too strict, you can edit the rules section of .eslintrc.cjs.
This process is normally performed automatically by a build&host service such as Netlify or Vercel.
However, you can run it yourself to observe the outputs.
yarn build
This will bundle your many source files into very few in dist/
, ready for deployment on a web server. As part of the process, it will convert your TypeScript files into JavaScript, using the TypeScript compiler, tsc
.
If you've run a local build, you can start a local server to host those files, using:
yarn preview
See Netlify with Git or more generally, "Deploying a Static Site" in the Vite Guide.
See package.json for other scripts.
- React app (hot-reloaded when you make changes)
- TypeScript
- ESLint and custom config
- Formatting with prettier
- Testing with
- vitest (jest-equivalent) and
- react-testing-library
- CI with GitHub Actions
- vscode default build task configured (in tasks.json) to type-check and lint to problems list
- vscode debugger launch config
- Vite
- Type-checking and linting errors presented into the browser (vite-plugin-checker)
- As little other junk as possible
(This is meant as an optional alternative to the excellent chrome devtools.)
- Start the dev server (e.g. yarn start)
- In vscode, switch to the "Run and debug" tab from the side menu
- At the top, click the green play button entitled "Launch Chrome against localhost"
- Browser should also launch, eventually
- Add breakpoint(s) to your react code in vscode, or add the
debugger
keyword - Interact with the React app so that your breakpoints /
debugger
keyword are encountered. - vscode's debugger should now present you with the local variables, the call stack, etc.
- Use the transport controls at the top to step through your code or continue execution
If you don't want to use vite-plugin-checker but you do want to get type-checking errors in the terminal, you can run dev and type-check at the same time by adding this script to package.json:
"dev-and-type-check": "npx concurrently 'vite --port 3000' 'tsc --noEmit --watch'"
- Vite guide
- About the
public
directory - Vite powerful React project setup (Camilo Martinez)