Vite
Vite
A next-generation frontend build tool. Based on ES modules. Faster than Webpack.
Vite
A next-generation frontend build tool. Based on ES modules. Faster than Webpack.
Vite (French for "fast") is a next-generation frontend build tool created by Evan You (the creator of Vue.js). During development, it uses native ES modules to start a server instantly without bundling, and for production builds it generates optimized bundles with Rollup.
There are two reasons Vite is fast. First, the development server does not pre-bundle all modules, but transforms them when the browser requests them. Second, it uses esbuild (written in Go) to perform dependency pre-bundling and TypeScript transpilation. As a result, cold starts are dozens of times faster.
Vite is framework-agnostic. It officially supports various templates such as Vue, React, Svelte, Solid, and Preact, and major meta-frameworks such as SvelteKit, Nuxt 3, and Astro are also based on Vite. Its plugin system is compatible with Rollup, so the ecosystem is rich.
In practice, Vite has become the de facto standard for new projects. Compared to Webpack, its configuration is simpler, HMR is fast at the millisecond level, and it supports TypeScript and CSS Modules out of the box. When you create a project with create-vite, the optimal configuration is applied automatically.
# Vite 프로젝트 생성
npm create vite@latest my-app -- --template react-ts
cd my-app && npm install && npm run dev
# vite.config.ts - 기본 설정
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true
}
}
},
build: {
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom'],
utils: ['lodash-es', 'date-fns']
}
}
}
},
resolve: {
alias: {
'@': '/src'
}
}
})
# 환경 변수 사용 (.env)
VITE_API_URL=https://api.example.com
# 코드에서 사용
const apiUrl = import.meta.env.VITE_API_URL;
"Let's start new projects with Vite. If you pick a template with npm create vite, TypeScript and ESLint are all set up. You can start developing right away, without having to create a complex configuration file like with Webpack."
"During development, Vite serves ES modules directly to the browser and pre-bundles only the dependencies with esbuild. Because it doesn't bundle the entire app like Webpack does, cold starts and HMR are fast. For production, it applies Tree Shaking and code splitting with Rollup."
"If you migrate from CRA to Vite, the dev server startup drops from several seconds to milliseconds. However, if you have Webpack-specific plugins, you may need to find Vite alternatives or write the plugins yourself."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Vite is based on ES modules. require() and CommonJS-only packages are converted through dependency pre-bundling, but some may require manual configuration.
Environment variables to be used in client code must start with VITE_. Otherwise, they will not be exposed at build time.
Explicitly include or exclude problematic dependencies with optimizeDeps, and simplify paths with alias. Most Rollup plugins can also be used as they are.