Overview
The SAAC Frontend template uses Vite 7.x as its build tool and development server. Vite provides lightning-fast Hot Module Replacement (HMR), optimized builds, and a rich plugin ecosystem.Configuration File
The Vite configuration is defined invite.config.ts at the project root:
vite.config.ts
Plugins
React SWC Plugin
The@vitejs/plugin-react-swc plugin enables React support with SWC (Speedy Web Compiler).
Why SWC over Babel?
Why SWC over Babel?
SWC is a Rust-based compiler that’s significantly faster than Babel:
- 20x faster compilation times
- Lower memory usage during development
- Faster HMR (Hot Module Replacement)
- Full TypeScript and JSX support built-in
- JSX transformation
- React Fast Refresh for instant HMR
- TypeScript transpilation
- Modern JavaScript features
Tailwind CSS Plugin
The@tailwindcss/vite plugin integrates Tailwind CSS v4 directly into Vite’s build pipeline.
Tailwind CSS v4 uses a native Vite plugin and doesn’t require PostCSS configuration.
- Just-in-Time (JIT) compilation
- Automatic CSS purging in production
- Fast HMR for CSS changes
- No additional PostCSS setup needed
Development Server
Default Settings
Vite’s default dev server configuration:The hostname to bind the dev server to
The port number for the dev server
Automatically open the browser on server start
Exit if port is already in use (instead of trying next port)
Customizing Dev Server
vite.config.ts
Build Configuration
Production Build Options
vite.config.ts
Build Options Explained
Build Options Explained
Output directory for production build
Generate source maps for debugging production builds
Minification method. esbuild is faster, terser produces smaller output
Browser compatibility target (es2015, es2020, etc.)
Path Aliases
Add path aliases for cleaner imports:vite.config.ts
Environment Variables
Vite exposes environment variables throughimport.meta.env:
.env
Only variables prefixed with
VITE_ are exposed to your client-side code.Commands
The following npm scripts use Vite:Advanced Configuration
CSS Preprocessing
vite.config.ts
Optimizing Dependencies
vite.config.ts
