Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
Configure and optimize Vite for development, production builds, and library bundling.
Configure and optimize Vite for development, production builds, and library bundling.
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
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
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
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
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 // vite.config.ts resolve: { alias: { '@': path.resolve(__dirname, './src') } }
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 server: { proxy: { '/api': { target: 'http://localhost:3000', changeOrigin: true, rewrite: path => path.replace(/^\/api/, '') } } }
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.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
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()
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.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
Code helpers, APIs, CLIs, browser automation, testing, and developer operations.
Largest current source with strong distribution and engagement signals.