Vite से App बनाना
npm create vite@latest app-name -- --template react
cd app-name
npm install
npm run dev
Vite इतना Popular क्यों है
Vite एक build tool है जो dev server almost instantly start करता है और आपके file save करने पर browser को milliseconds में update करता है, क्योंकि यह आपकी source files को native ES modules के through directly serve करता है पहले से सब कुछ bundle करने के बजाय जैसे older tools करते हैं।
उदाहरण: Why Vite Is Popular
$ npm create vite@latest my-app -- --template react
$ npm run dev
ready in 180ms
⚠️ Run this in your own terminal or Node.js environment.
Vite की Project Structure
एक Vite + React project में project root पर एक index.html है (public/ के अंदर नहीं, CRA के विपरीत), entry point के रूप में main.jsx के साथ एक src/ folder, और build settings के लिए एक vite.config.js file।
उदाहरण: Vite's Project Structure
$ ls -R my-app
my-app:
index.html node_modules package.json public src vite.config.js
my-app/public:
vite.svg
my-app/src:
App.css App.jsx assets index.css main.jsx
⚠️ Run this in your own terminal or Node.js environment.
Vite के साथ Run और Build करना
npm run dev Vite का development server start करता है; npm run build एक optimized production bundle एक dist/ folder में बनाता है, deploy करने के लिए ready।
उदाहरण: Running and Building with Vite
npm run dev # local dev server
npm run build # bundles into dist/
⚠️ Run this in your own terminal or Node.js environment.
npm create vite@latestrun करते समय React template select करना भूल जाना।- Create React App जैसी exact file structure की उम्मीद करना -- Vite के defaults थोड़े अलग हैं।
- एक Vite project clone करने के बाद
npm run devसे पहलेnpm installन run करना।
- Vite एक fast, modern build tool है जो अब एक React project शुरू करने का recommended तरीका है।
- यह development के दौरान near-instant server start और hot reload के लिए native ES modules उपयोग करता है।
npm create vite@latestएक template picker के साथ एक नया project scaffold करता है।npm run devdev server start करता है;npm run buildproduction bundle बनाता है।
Generated app सभी modern evergreen browsers को support करता है; Vite का dev server खुद सिर्फ development के दौरान browser में native ES module support पर depend करता है।
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: