Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 9, 2022 05:37 pm GMT

Have you used - Vite ( Frontend Tool) ??

Say you want to start a new React project, the first thing you will do is run

npx create-react-app my-app

Now you have to manually install all the required dependencies. Now this process will take 4-5 mins on an average.

Enter Vite

Vite is a build tool that promotes a faster development experience for developers. It was created by Evan You.

  1. Hot Module ReplacementA fast development server, that provides swift Hot Module Replacement (HMR), due to its enhanced features.

You can read more about ES native modules from here.

  1. RollupVite has a build command that bundles the developers code with Rollup.

This is a JavaScript module bundler that compiles simple pieces of code and builds them into complex applications.

Since Rollup is pre-configured, its easy to generate static applications that are highly optimized for production.

Benefits of Vite

A developers productivity is influenced by many factors including performance and speed.

JavaScript can cause an application to slow down depending on its complexity. Vite resolves this issue by using Esbuild.

EsBuild is a dependency pre-bundler that enhances the pre-bundling of dependencies than other frameworks. This results in increased server speeds and Hot Module Replacement.

Features of Vite

The key features of Vite include:

  • Instant server start.
  • Fast Hot Module Replacement.
  • Optimized build process.

Lets now create a React application using Vite.

Creating a react application using Vite.

Navigate to your desktop and create a new folder. This directory will store all of our files.

Write the following command in your CLI.

npm init vite

You will see different process running on the screen those are product dependencies and build packages.

Our project is now created. Lets install and then run it.

Image description

Your package.json file should look, as shown below:

Image description

Finally, include the following command to start the dev server:

npm run dev

Copy and paste the provided link on your browser. You now have React and Vite running on your local server. Congratulations!

Image description


Original Link: https://dev.to/sanjaysinghrajpoot/have-you-used-vite-frontend-tool--mj1

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To