

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Install TypeScript
incomplete
2: tsconfig.json
incomplete
3: More tsconfig.json
incomplete
4: Declaration Files
incomplete
5: Using JS Libraries
incomplete
6: TypeScript Language Server
incomplete
7: TypeScript Ignore
incomplete
8: Vanilla Vite
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Okay we've built our little TypeScript script, and used tsc to compile it manually. But let's scrap all that and scaffold a front-end project using Vite.
It's quite rare these days to build a front-end application without some sort of build tool. I'm not saying you can't – we just did – I'm just saying I don't see it often in the wild. Especially considering most front-end frameworks (React, Vue, Svelte, etc.) have their own build tools.
Vite is a new(ish) build tool that focuses on speed and simplicity. It does a few key things that make it great for many projects, and even vanilla TypeScript apps:
Fast: Vite uses the Golang-powered esbuild to do heavy lifting, which is partially why it's so fast. It also uses Rollup under the hood for production builds.
Simple: Vite is simple to use and configure, at least for a JS/TS tool (look, we're comparing it to Webpack here, so it's all relative).
Server: Vite has a built-in development server that serves your files and handles hot module replacement (HMR) for you.
Compiler: Vite compiles your code in development on the fly, so you don't have to manually rebuild each time you make a change.
npm i -D vitenpm create vite@latest . -- --template vanilla-tsnpm inpm run devTake a look at the package.json. Notice that it has vite and typescript as dependencies now. The dev command we ran simply runs tsc to compile your code and vite to serve it, all in one step.
Press Ctrl+C in the terminal to stop the dev server when you're done.
Notice that when you update the code and save the file, Vite will automatically recompile your code and update the browser for you!
Run and submit the CLI tests.