Vite is too fast!

karanpratapsingh

Karan Pratap Singh

Posted on July 18, 2021

Vite is too fast!

Recently I tried Vite and I was blown away by how fast it was. I re-checked if I started the app correctly because I couldn't belive that it started the dev server under 200ms!

So, here's a short article on what is Vite and how can we create a new react project with it.

What is Vite?

Vite is build tool created by Evan You (creator of Vue), it provides faster developement experience with instant server start, super fast Hot Module Replacement (HMR) and out of the box support for TypeScript as well.

Vite pre-bundles dependencies using esbuild. Esbuild is written in Go and pre-bundles dependencies 10-100x faster than other JavaScript-based bundlers.

Blazing fast TypeScript with Webpack and ESBuild If you'd like to learn more about esbuild setup with Webpack 5

Create a new project

Let's create a new project with Vite

yarn create vite
Enter fullscreen mode Exit fullscreen mode

vite select framework

template select

vite done

And we have our vite project πŸŽ‰!

β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ App.css
β”‚   β”œβ”€β”€ App.tsx
β”‚   β”œβ”€β”€ favicon.svg
β”‚   β”œβ”€β”€ index.css
β”‚   β”œβ”€β”€ logo.svg
β”‚   β”œβ”€β”€ main.tsx
β”‚   └── vite-env.d.ts
β”œβ”€β”€ tsconfig.json
└── vite.config.ts
Enter fullscreen mode Exit fullscreen mode

Let's start our dev server

cd vite-project
yarn install
yarn dev
Enter fullscreen mode Exit fullscreen mode

vite dev

Build

Vite uses rollup to build and optimize static assets. Let's build our project

yarn build
Enter fullscreen mode Exit fullscreen mode

vite build

We have our static assets ready to be served!

πŸ’– πŸ’ͺ πŸ™… 🚩
karanpratapsingh
Karan Pratap Singh

Posted on July 18, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related