This is a basic working dev environment for working on a React/Typescript application, including TailwindCSS, and using next generation tooling from Vite. In addition running lambda's from Netlify/Typescript in the same environment.
✅ Tested with netlify-cli/3.29.7 darwin-x64 node-v15.13.0
✅ Tested with netlify-cli/3.29.7 darwin-x64 node-v16.1.0
✅ Tested with netlify-cli/3.29.7 darwin-x64 node-v12.0.0
✅ Tested with netlify-cli/4.1.2 win32-x64 node-v16.13.1
First fork this repo and then clone your fork, then:
npm install
netlify init
Configure as you see fit, but the netlify.toml file does specify a build command and you'll need to change that to override it.
npm start
If you fork the repo, then want to use it again, you might try the following:
- Click the Use This Template on the repo to make a new one.
OR
- Create your new repo on GitHub
git clone yournewrepo
git clone --bare your-fork-of-this-starter
cd your-fork-of-this-starter
git push --mirror yournewrepo
rm -rf your-fork-of-this-starter.git
rm -rf yournewrepo
git clone yournewrepo
You're netlify endpoint is now: localhost:3000/api/{function}
You can tell you are on the proper localhost port, because when you start the server vite tells you:
[⚡️vite] > Local: http://localhost:3000/
I like seeing typescript errors in my console, as well as using VS Code, or any other modern text editor, so we run tsc concurrently with vite and it's HMR. The output then looks something like this:
[⚡️vite] ready in 238ms.
[👹tsc] 4:42:46 PM - Found 0 errors. Watching for file changes.
You can change this inside package.json, the "dev" script.
"concurrently -n \"⚡️vite,👹tsc\" -c \"cyan,red\" \"vite\" \"tsc -w\""
-n specifies to names for each command output
-c specifies the color for each command output
If you don't want to see any tsc errors in the command line, just remove "-w". This means that you will see typescript errors on the inital vite build, but not after that.
Currently it is set to error before build if typescript errors don't pass. This means that Netlify won't deploy either, if there are typescript errors. Based on the tsconfig.json, we are also checking the functions folder when we run tsc.
You can change this inside package.json, the "build" script.
"tsc && vite build"
Just remove tsc, but remember that it can be nice to be notified of potential errors before you build.
Netlify is awesome, so you can actually just deploy your app by pushing to whatever branch you have Netlify watching.
You can deploy a draft with:
netlify deploy
Or if you want it in production
netlify deploy --prod
The starter kit's deployed site is here.