How to initialize a project based on react+vite

The following are the basic steps to use Reactand Vitebuild a front-end project:

Installation Node.jsand npmpackage managers. You can Node.jsdownload and install Node.js and npm.

In a terminal or command line interface, run the following command to globally install the latest version of Vite:

npm install -g vite

Change into the directory where you want to create the project and initialize a new React project with the following command:

npm init vite my-react-app --template react

Among them, my-react-appis the name of the project you want to create, --template reactspecifying to use the React template to create the project.

Go into the project directory and install project dependencies:
bash
Copy code

cd my-react-app
npm install

Start Vitethe development server by running the following command:

npm run dev

Open a browser and type in the address bar http://localhost:3000/to access the default page of the React application.

You have now successfully created a Reactand Vitescaffolded front-end project. You can start adding business logic and UI components to develop your application.

When you Vitebuild Reactan application with , Viteit automatically uses the latest version Reactand supports hot reloading, that is, after modifying the code, the browser will automatically update to show the latest changes. In addition, Vitesupport TypeScriptand CSSpreprocessors, as well as a variety of plugins and tool integrations.

Guess you like

Origin blog.csdn.net/gkf6104/article/details/129628665