Welcome to our Vite JS tutorial! This guide will walk you through creating and analyzing the output of a Vite project.
Vite is a modern, fast, and developer-friendly tool for building modern web projects. It combines the speed of a development server with the optimized build of production assets.
To start, let's install Vite globally:
npm install -g viteNow, create a new Vite project:
vite create my-vite-appNavigate into your project:
cd my-vite-appStart the development server:
npm run devNow, open your browser at http://localhost:5000 to see your project.
my-vite-app/
└── src/
├── main.js
├── index.html
└── style.cssEach file represents a different part of your project:
main.js: Entry point for your JavaScript codeindex.html: Basic HTML structure for your projectstyle.css: Entry point for your CSS stylesTo build the project, run:
npm run buildVite will optimize and bundle your assets, creating a dist folder with the optimized files.
Let's take a closer look at the build output:
my-vite-app/
└── dist/
├── index.html
├── main.js
├── style.css
└── manifest.jsonindex.html: The optimized HTML structure of your projectmain.js: The optimized JavaScript bundlestyle.css: The optimized CSS bundlemanifest.json: Metadata for your projectTo run the built project, use a local server like http-server:
npm install http-server -g
http-server distNow, open your browser at http://localhost:8080 to see your optimized project.
Which command starts the development server for a Vite project?
What is the name of the folder that contains the optimized files after building a Vite project?