Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Configure Optimize Vite Builds

ASecurity

Configure and optimize Vite for development, production builds, and library bundling.

19 stars
0 votes
0 copies
1 views
Added 9/19/2026
developmenttypescriptgoreactvuenodedebugginggitapiperformance

Works with

cliapi

Security Analysis

A100/100

Scanned 9/19/2026

Install to Claude Code

$npx -y skills add rondoflow/rondoflow --skill configure-optimize-vite-builds --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Configure Optimize Vite Builds?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Configure Optimize Vite Builds
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rondoflow-configure-optimize-vite-builds/badge)](https://www.skillsdirectory.com/skills/rondoflow-configure-optimize-vite-builds)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: configure-optimize-vite-builds
description: "Configure and optimize Vite for development, production builds, and library bundling."
category: "Development"
author: community
version: "1.0.0"
icon: code
---

# Vite Patterns

## Environment Variables
- Only `VITE_` prefixed vars are exposed to client code — `DB_PASSWORD` stays server-side, `VITE_API_URL` is bundled
- Access via `import.meta.env.VITE_*` not `process.env` — process.env is Node-only and undefined in browser
- `.env.local` overrides `.env` and is gitignored by default — use for local secrets
- `import.meta.env.MODE` is `development` or `production` — use for conditional logic, not `NODE_ENV`

## CommonJS Compatibility
- Pure ESM by default — CommonJS packages need `optimizeDeps.include` for pre-bundling
- `require()` doesn't work in Vite — use `import` or `createRequire` from `module` for dynamic requires
- Some packages ship broken ESM — add to `ssr.noExternal` or `optimizeDeps.exclude` and let Vite transform them
- Named exports from CommonJS may fail — use default import and destructure: `import pkg from 'pkg'; const { method } = pkg`

## Dependency Pre-bundling
- Vite pre-bundles dependencies on first run — delete `node_modules/.vite` to force rebuild after package changes
- Large dependencies slow down dev server start — add rarely-changing ones to `optimizeDeps.include` for persistent cache
- Linked local packages (`npm link`) aren't pre-bundled — add to `optimizeDeps.include` explicitly
- `optimizeDeps.force: true` rebuilds every time — only for debugging, kills dev performance

## Path Aliases
- Configure in both `vite.config.ts` AND `tsconfig.json` — Vite uses its own, TypeScript uses tsconfig
- Use `path.resolve(__dirname, './src')` not relative paths — relative breaks depending on working directory
- `@/` alias is not built-in — must configure manually unlike some frameworks

```typescript
// vite.config.ts
resolve: {
  alias: { '@': path.resolve(__dirname, './src') }
}
```

## Dev Server Proxy
- Proxy only works in dev — production needs actual CORS config or reverse proxy
- `changeOrigin: true` rewrites Host header — required for most APIs that check origin
- WebSocket proxy needs explicit `ws: true` — HTTP proxy doesn't forward WS by default
- Trailing slashes matter: `/api` proxies `/api/users`, `/api/` only proxies `/api//users`

```typescript
server: {
  proxy: {
    '/api': {
      target: 'http://localhost:3000',
      changeOrigin: true,
      rewrite: path => path.replace(/^\/api/, '')
    }
  }
}
```

## Static Assets
- `public/` files served at root, not processed — use for favicons, robots.txt, files that need exact paths
- `src/assets/` files are processed, hashed, can be imported — use for images, fonts referenced in code
- Import assets to get resolved URL: `import logo from './logo.png'` — hardcoded paths break after build
- `new URL('./img.png', import.meta.url)` for dynamic paths — template literals with variables don't work

## Build Optimization
- `build.rollupOptions.output.manualChunks` for code splitting — without it, one giant bundle
- Analyze bundle with `rollup-plugin-visualizer` — find unexpected large dependencies
- `build.target` defaults to modern browsers — set `'es2015'` for legacy support, but increases bundle size
- `build.cssCodeSplit: true` (default) — each async chunk gets its own CSS file

## Library Mode
- `build.lib` for npm packages — different config from app mode
- Set `external` for peer dependencies — don't bundle React/Vue into your library
- Generate types separately with `tsc` — Vite doesn't emit `.d.ts` files
- Both ESM and CJS outputs: `formats: ['es', 'cjs']` — some consumers still need require()

## HMR Issues
- Circular imports break HMR — refactor to break the cycle or full reload triggers
- State lost on HMR means component isn't accepting updates — check for `import.meta.hot.accept()`
- CSS changes trigger full reload if imported in JS that doesn't accept HMR — import CSS in components that do
- `server.hmr.overlay: false` hides error overlay — useful for custom error handling but hides issues

## SSR Configuration
- `ssr.external` for Node-only packages — prevents bundling node_modules in SSR build
- `ssr.noExternal` forces bundling — needed for packages with browser-specific imports
- CSS imports fail in SSR by default — use `?inline` suffix or configure `css.postcss` for SSR

Attribution

rondoflowrondoflow
View sourceMore from rondoflow →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284722 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2192 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →