Logo
AndreaDSW
BETA

Building web applications with Vite. Experimental approach

Last Modified:

An experimental guide to building fast and efficient web applications using Vite as the build tool.

I started an experimental development with Vite.js. My primary objectives were to see what Vite provides out of the box compared to React.js projects that I still need to maintain some of them.

What I found was really interesting, the development experience was fantastic faster and simple. If I were required to create a basic single-page application (SPA), like dashboards or any prototype, I would most likely go with Vite.

I had few questions in my mind: Can Vite take the place of React? Is it time to switch? Or are there any similarities between them?

Vite (pronounced “veet”) was developed by Evan You, the same guy behind Vue.js. It became one of favourites tooling for front end developers. I went to a journey to discover why?

I easily set up a web applications very quickly without too much headaches. It says what is in the box providing a faster development experience. I no longer have to deal with the hassles of having numerous scripts in React to launch and build the application. Additionally, adjusting the webpack settings is not needed anymore.

In contrast to React’s webpack-dev-server, Vite uses Rollup under the hood makes it considerably faster. Additionally, it has in as a core ES module to create its own server.

React’s scripts in package.json

JSON
"scripts": {  "start": "NODE_ENV=development webpack serve --config config/webpack.config.dev.js",  "start": "node scripts/start.js",  "build:dev": "NODE_ENV=development node scripts/build.js",  "build:prod": "NODE_ENV=production node scripts/build.js",}

Vite provides native ES modules, serving the code to the browsers without bundling everything. It reloads must faster because, it does not need to rebuild the whole bundle. Only the changes made are instantly reloaded in the browser. Furthermore, complicated CSS, JSX, and TypeScript setting is not required.

Vite’s scripts in package.json

JSON
"scripts": {  "dev": "vite",  "build": "tsc && vite build",  "preview": "vite preview",},

Most importantly, it is framework agnostic which I can use with React to build the components UI and the navigation router. Likewise, give to developers freedom to make some architecture decisions about libraries, patterns, and data retrieval from the backend.

I can understand why developers use Vite these days. Because of less configuration, fast load times and better and cleanest development experience. Choosing Vite doesn’t just make developers life easier and and creative process more enjoyable. From the user points of view the web apps are faster with performance loops much lighter.