What is Vitejs? An Overview of the New Front-end Build Tool

What is Vitejs? An Overview of the New Front-end Build Tool

Learn how simple it is to get up and running with Vite. With Vite, you can be up and running with Vue, React and even vanilla JS in just a few clicks. Vite is a build tool that significantly improves the front-end development experience.

Need a simpler way to set up a front-end dev environment? With Vite, you can be up and running with Vue, React and even vanilla JS in just a few clicks.

Vite is a build tool that significantly improves the front-end development experience. You can use Vite to set up a development environment for frameworks like Vue and React, and even for a vanilla JavaScript app with a dev server and hot reloading in just three commands.

With no extra configuration, you can also use Vite for TypeScript, and with one additional command you can use it for Sass. (That would take a lot of config for a webpack project. You’d need to mess around with loaders and separately install the webpack dev server.)

Once you have Vite installed, you’ll have a build tool and dev server and be ready to start working with the latest tools and languages.

In this introduction, you’ll learn how simple it is to get up and running with Vite. You’ll also learn about how fast Vite is, how to take the first steps towards using it with a library such as Vue, and how much it gets out of your way when you’re using it.

Fun fact: the name “Vite” comes from the French word for “fast”, which is pronounced “vit”.

How Vite Works

Vite follows a recent trend of tools like Svelte (where the framework is basically compiled away) and other tools like Snowpack that leverage modern JavaScript features (such as ES modules) to provide a smooth, fast dev experience with little to no configuration and not much overhead in the way of installed packages. You basically install Vite with a plugin or two, do very little configuration, and just start working on your app.

Vite provides a modern dev environment that can forego the bundling step because it serves the browser native ES modules. It provides templates (a set of starter files) for a number of frameworks and vanilla JavaScript, and also offers TypeScript, JSX and Sass support (although you need to install one dependency for Sass).

Vite is really fast, because it leverages native ES modules and doesn’t need to rebuild the whole bundle when something changes. This makes HMR updates consistently fast, regardless of the size of your application. When bundling for production, Vite ships with a pre-configured build command that bakes in many performance optimizations out of the box.

As well as being fast, Vite also offers hot module replacement (meaning you see the code refresh in the browser as you develop), and you can use it to compile a minified version of your project to serve in production. By using it, you can get up and running very quickly with a Vue or React project without the buy-in to the Vue CLI or Create React App, both of which ship with the kitchen sink included. This makes it ideal for quick prototyping and smaller projects, although there’s nothing stopping you from using it in a larger project either.

So, let’s take Vite for a spin and see how we go. It will be interesting to see how much of our normal workflow would be better handled with Vite. (Spolier: I found some things were better with Vite, but not everything.)

The First Installation

Let’s get started by installing Vite.

Note: to follow along with this guide, you’ll need a copy of Node installed on your machine.

After running npm init @vitejs/app, we get to choose a project name and a template. At the time of writing, the options are:

  • vanilla
  • vue
  • vue-ts
  • react
  • react-ts
  • preact
  • preact-ts
  • lit-element
  • lit-element-ts
  • svelte
  • svelte-ts

For now, let’s go with vanilla. This generates a directory (based on the project name) with some files in it. There’s an index.htmlmain.jsstyle.cssfavicon.svg, and some files for npm and Git. The package.json only contains vite as dependency and some scripts to start the dev environment and to start a build.

vitejs javascript web-development angular react

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Hire Dedicated JavaScript Developers -Hire JavaScript Developers

Hire dedicated JavaScript Developers who are proficient in AngularJS, ReactJS, NodeJS, & VueJS frameworks. Get flexible hiring models as per your business requirements.

Hire Top Angular Developers | Hire Angularjs Developer India

Hire dedicated Angular JS developers & programmers in India for custom full-stack AngularJS app development projects on an hourly / full-time basis. Strict NDA, 16+ years exp & 2500+ clients|450+ Experts

Hire Top Angular Developers | Hire Angularjs Developer India

Hire dedicated Angular JS developers & programmers in India for custom full-stack AngularJS app development projects on an hourly / full-time basis. Strict NDA, 16+ years exp & 2500+ clients|450+ Experts

Angular Web Application Development

Skenix Infotech is a top-notch Angular development company providing customized AngularJS development services. Hire reliable & expert Angular developers from us.