vite

Vite build tool configuration and ecosystem. Covers vite.config.ts setup, plugin authoring and popular plugins, dev server configuration (proxy, HMR, HTTPS), build optimization (chunking, tree-shaking, manual chunks, rollupOptions), library mode for publishing packages, SSR configuration, environment variables (.env handling), multi-page apps, CSS handling (PostCSS, CSS modules, preprocessors), and asset handling. Use when configuring Vite projects, authoring Vite plugins, optimizing builds, setting up dev server proxies, configuring SSR, handling environment variables, or troubleshooting Vite issues.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "vite" with this command: npx skills add oakoss/agent-skills/oakoss-agent-skills-vite

Vite

Overview

Vite is a next-generation frontend build tool that provides instant dev server start via native ES modules and optimized production builds via Rollup. It supports TypeScript, JSX, CSS preprocessors, and static assets out of the box with zero configuration.

When to use: Single-page apps, multi-page apps, library publishing, SSR applications, monorepo packages, any modern frontend project needing fast dev feedback and optimized builds.

When NOT to use: Legacy browsers requiring ES5 output without transpilation, projects locked to Webpack-specific loaders with no Vite equivalents, non-JavaScript build pipelines.

Quick Reference

PatternAPIKey Points
Config filedefineConfig({})Type-safe config with IDE support
Conditional configdefineConfig(({ command, mode }) => ({}))Different config per command/mode
Path aliasresolve.aliasMap @/ to src/
Dev proxyserver.proxyForward API requests to backend
HMR configserver.hmrWebSocket host/port/protocol
HTTPS devserver.httpsPass TLS cert/key options
Build targetbuild.targetES module target for output
Manual chunksbuild.rollupOptions.output.manualChunksControl code splitting
Library modebuild.libPublish ES/CJS/UMD packages
SSR buildbuild.ssr + ssr optionsServer-side rendering config
Env variablesimport.meta.env.VITE_*Client-exposed env vars
loadEnvloadEnv(mode, root, prefix)Load env vars in config
CSS modulescss.modulesScoped CSS class names
Preprocessorscss.preprocessorOptionsSass/Less/Stylus options
PostCSScss.postcssInline or external PostCSS config
Static assetsimport url from './img.png'Returns resolved public URL
Plugin{ name, transform, load }Hook-based plugin system
Virtual moduleresolveId + load hooksGenerate modules at build time
Multi-pagebuild.rollupOptions.inputMultiple HTML entry points

Common Mistakes

MistakeCorrect Pattern
Exposing secrets via VITE_ prefixOnly prefix client-safe vars with VITE_; use loadEnv in config for server-only secrets
Using process.env in client codeUse import.meta.env.VITE_* (Vite replaces at build time)
Modifying rollupOptions.input without resolve()Always use path.resolve() or import.meta.dirname for absolute paths
Not externalizing peer deps in library modeAdd React/Vue to rollupOptions.external to avoid bundling
Creating QueryClient-style singletons in SSREnsure per-request state in SSR to avoid cross-request leaks
Inline PostCSS config alongside postcss.config.jsUse one or the other; inline config disables config file search
Setting base without trailing slashbase should be /path/ with trailing slash or full URL
Using __dirname in ESM configUse import.meta.dirname (Node 21+) or fileURLToPath

Delegation

  • Plugin discovery: Use Explore agent
  • Build analysis: Use Task agent
  • Config review: Delegate to code-reviewer agent

If the vitest-testing skill is available, delegate test configuration and Vitest setup to it. If the tailwind skill is available, delegate Tailwind CSS configuration and utility patterns to it. If the react-patterns skill is available, delegate React component patterns and hooks to it. If the typescript-patterns skill is available, delegate TypeScript configuration and type patterns to it. If the pnpm-workspace skill is available, delegate monorepo workspace configuration to it.

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

github-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tanstack-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

typescript-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tanstack-devtools

No summary provided by upstream source.

Repository SourceNeeds Review