Top Related Projects
Set up a modern web app by running one command.
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
The zero configuration build tool for the web. 📦🚀
ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
👩🚀 The tiny all-in-one development tool for modern web apps.
Quick Overview
Vite is a modern build tool and development server for web applications. It leverages native ES modules in the browser to provide an extremely fast development experience, with instant server start and lightning-fast hot module replacement (HMR).
Pros
- Extremely fast development server with instant startup
- Out-of-the-box support for TypeScript, JSX, CSS, and more
- Optimized build command for production with code-splitting and lazy-loading
- Plugin-based architecture for easy extensibility
Cons
- Relatively new compared to established tools like webpack
- May require adjustments for projects with complex build requirements
- Limited compatibility with older browsers that don't support ES modules
- Learning curve for developers accustomed to traditional bundlers
Code Examples
- Creating a Vite project:
npm create vite@latest my-vite-project -- --template react
cd my-vite-project
- Using CSS modules:
import styles from './styles.module.css'
function MyComponent() {
return <div className={styles.example}>Hello, Vite!</div>
}
- Configuring Vite:
// vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
},
build: {
outDir: 'dist',
},
})
Getting Started
To start using Vite in your project:
-
Create a new Vite project:
npm create vite@latest my-project -- --template vue cd my-project
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Build for production:
npm run build
Your application will be built and ready for deployment in the dist
directory.
Competitor Comparisons
Set up a modern web app by running one command.
Pros of Create React App
- Mature ecosystem with extensive documentation and community support
- Simplified setup process with zero configuration required
- Includes a comprehensive set of pre-configured tools and optimizations
Cons of Create React App
- Slower build times and development server startup
- Less flexibility for customization without ejecting
- Larger bundle sizes due to inclusion of unnecessary dependencies
Code Comparison
Create React App:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />, document.getElementById('root'));
Vite:
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
The main difference in the code is how the React application is rendered. Create React App uses the older ReactDOM.render()
method, while Vite uses the newer ReactDOM.createRoot()
API for concurrent rendering.
Vite offers faster build times, a more flexible configuration, and smaller bundle sizes. It uses native ES modules for development, resulting in quicker startup and hot module replacement. However, Create React App remains a popular choice for its stability, extensive documentation, and well-established ecosystem, making it ideal for beginners or projects that don't require advanced customization.
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
Pros of webpack
- More mature and battle-tested ecosystem with extensive plugin support
- Greater flexibility for complex configurations and custom build processes
- Better support for older browsers and legacy code bases
Cons of webpack
- Slower build times, especially for larger projects
- Steeper learning curve and more complex configuration
- Requires more boilerplate code to set up a project
Code Comparison
webpack configuration:
module.exports = {
entry: './src/index.js',
output: { filename: 'bundle.js' },
module: { rules: [{ test: /\.js$/, use: 'babel-loader' }] }
};
Vite configuration:
export default {
build: { target: 'esnext' },
plugins: []
};
Vite focuses on simplicity and speed, leveraging native ES modules for development. It requires minimal configuration and provides faster build times, especially for modern web applications. Webpack offers more control and customization but at the cost of complexity and slower builds. Vite is ideal for projects using modern JavaScript, while webpack remains a solid choice for projects with legacy requirements or complex build processes.
The zero configuration build tool for the web. 📦🚀
Pros of Parcel
- Zero configuration out of the box, making it easier for beginners
- Supports a wider range of file types and assets without additional plugins
- Faster initial build times for smaller projects
Cons of Parcel
- Less flexible for complex configurations and custom setups
- Slower hot module replacement (HMR) compared to Vite
- Limited ecosystem and community support compared to Vite
Code Comparison
Parcel:
// No configuration needed, just run:
parcel index.html
Vite:
// vite.config.js
export default {
// Basic configuration options
root: './src',
build: {
outDir: './dist'
}
}
Key Differences
- Vite uses native ES modules for dev server, resulting in faster HMR
- Parcel aims for zero-config, while Vite offers more customization
- Vite has better TypeScript support and integration with modern frameworks
- Parcel handles a broader range of assets out of the box
- Vite has a larger and more active community, leading to better long-term support
Both tools are excellent choices for modern web development, with Parcel being more beginner-friendly and Vite offering better performance and flexibility for larger projects.
ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
Pros of Snowpack
- Simpler configuration and faster initial setup
- Better support for non-JavaScript files and assets
- More intuitive plugin system for extending functionality
Cons of Snowpack
- Slower build times for larger projects
- Less robust ecosystem and community support
- Limited hot module replacement (HMR) capabilities
Code Comparison
Snowpack configuration:
// snowpack.config.js
module.exports = {
mount: {
public: '/',
src: '/dist',
},
plugins: ['@snowpack/plugin-react-refresh'],
};
Vite configuration:
// vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
})
Both Snowpack and Vite aim to provide fast, modern development experiences for web applications. Snowpack offers a simpler setup and better handling of non-JavaScript files, while Vite excels in build performance and has a more extensive ecosystem. The code comparison shows that both tools have relatively straightforward configuration files, with Snowpack's config being slightly more verbose but potentially more intuitive for beginners. Ultimately, the choice between the two depends on project requirements and personal preferences.
👩🚀 The tiny all-in-one development tool for modern web apps.
Pros of WMR
- Smaller bundle size and faster build times for Preact-specific projects
- Built-in support for service workers and PWA features
- Simpler configuration with fewer options, making it easier for beginners
Cons of WMR
- Limited ecosystem compared to Vite's broader plugin support
- Less flexibility for non-Preact projects or complex build requirements
- Smaller community and fewer resources for troubleshooting
Code Comparison
WMR:
// wmr.config.js
export default {
alias: {
react: 'preact/compat',
'react-dom': 'preact/compat'
}
}
Vite:
// vite.config.js
import { defineConfig } from 'vite'
export default defineConfig({
resolve: {
alias: {
react: 'preact/compat',
'react-dom': 'preact/compat'
}
}
})
Both WMR and Vite offer similar configuration options, but Vite's setup is more verbose and flexible. WMR's configuration is more concise and tailored specifically for Preact projects, while Vite's approach allows for greater customization across various frameworks and libraries.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Vite â¡
Next Generation Frontend Tooling
- ð¡ Instant Server Start
- â¡ï¸ Lightning Fast HMR
- ð ï¸ Rich Features
- ð¦ Optimized Build
- ð© Universal Plugin Interface
- ð Fully Typed APIs
Vite (French word for "quick", pronounced /vit/
, like "veet") is a new breed of frontend build tooling that significantly improves the frontend development experience. It consists of two major parts:
-
A dev server that serves your source files over native ES modules, with rich built-in features and astonishingly fast Hot Module Replacement (HMR).
-
A build command that bundles your code with Rollup, pre-configured to output highly optimized static assets for production.
In addition, Vite is highly extensible via its Plugin API and JavaScript API with full typing support.
Packages
Package | Version (click for changelogs) |
---|---|
vite | |
@vitejs/plugin-legacy | |
create-vite |
Contribution
See Contributing Guide.
License
MIT.
Sponsors
Top Related Projects
Set up a modern web app by running one command.
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
The zero configuration build tool for the web. 📦🚀
ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
👩🚀 The tiny all-in-one development tool for modern web apps.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot