,

Starting with Vite: A Beginner’s Guide

Posted by






Getting started with Vite

Getting started with Vite

Vite is a build tool that offers a highly efficient development experience for modern web applications. It is designed to enhance the development workflow by focusing on fast and instant reloading, making it an excellent choice for developers looking for a speedy development environment.

Installation

To start using Vite, you need to have Node.js installed on your machine. Once you have Node.js, you can install Vite by using npm, the package manager that comes bundled with Node.js. Open your command line interface and run the following command:


npm install -g create-vite

This command will install the create-vite package globally on your machine, allowing you to create new Vite projects whenever you want.

Creating a new Vite project

To create a new Vite project, navigate to the folder where you want to create your project in your command line interface and run the following command:


npx create-vite my-project

This command creates a new Vite project in a folder named my-project. You can replace my-project with the desired name for your project.

Running the development server

Once you have created your Vite project, navigate to the project folder in your command line interface. Run the following command to start the development server:


cd my-project
npm install
npm run dev

This will start the development server, and you can access your project by opening your browser and navigating to http://localhost:3000. You will see your project running with hot module reloading, allowing you to see your changes instantly without having to manually refresh the page.

Building for production

When you are ready to deploy your Vite project, you need to build it for production. Run the following command in your project folder:


npm run build

This command will generate a production-ready build of your project, optimized for performance. The built files will be placed in a dist folder in your project directory, ready to be deployed to a web server.

With these basic steps, you can get started with Vite and enjoy its fast development experience. Happy coding!


0 0 votes
Article Rating
7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Tyas Dwi Angga
7 months ago

We dont need something outta context talking bro, just straight to the learning. cant just wasting time listening to unnecessary things!

Mike Lazrou
7 months ago

Thank you Alvaro for this video, can you do a video how to deploy to github actions using pnpm and vite ?

Cameron Loken
7 months ago

Is it possible to serve assets from a local environment without running a server? Similar to just a static website. If not, could you create a bundled app that runs off your desktop? Just curious. Great video by the way!

TheUnknownDev
7 months ago

Plugins with vite solo video? Yes please!

Bizhan Hejazi
7 months ago

I have been searching YouTube for such a concise video about Vite for 2 days! what this guy has done is awesome.

Luis Antonio Herrera
7 months ago

Excelente trabajo, Alvaro. Looking forward to the plugin tutorial!

CodewithGuillaume
7 months ago

Thanks Alvaro that is dope.

Vite can seems very intimidating for juniors at first. But it's actually sooo easy to use.

Best !