Cơ BảnBuild Tools iconBuild Tools

Vite là gì? Tại sao nhanh hơn Webpack trong development?

Vite là build tool thế hệ mới của Evan You.

  • Dev server không bundle — browser request file nào thì Vite transform file đó on-demand qua native ESM, cold start gần như instant bất kể project size. esbuild pre-bundling: lần đầu start, Vite dùng esbuild (Rust-based, 10-100x nhanh hơn JS bundlers) để bundle node_modules thành single module — tránh browser phải request hàng nghìn files nhỏ; result được cache trong node_modules/.vite.
  • Native ESM serving: source files served dưới dạng ES modules trực tiếp, browser handle dependency graph — chỉ transform file cần thiết cho request hiện tại.
  • Production: dùng Rollup để bundle vì Rollup có tree shaking tốt hơn và output nhỏ hơn esbuild cho production; cũng dùng esbuild để minify (nhanh hơn Terser).
  • Plugin ecosystem: Vite plugins compatible với Rollup plugin API — vite-plugin-react (React Fast Refresh), @vitejs/plugin-vue, vite-plugin-pwa.
  • Framework integrations: Vite là foundation cho SvelteKit, Qwik, Astro, và Remix (một phần).
  • HMR: chỉ invalidate module thay đổi và direct importers — không re-process toàn bộ bundle graph.

Xem toàn bộ Build Tools cùng filter theo level & chủ đề con.

Mở danh sách Build Tools