搜索

PythonReactSEOPDF
GitHub Skill

vite-dev

Vite development server setup, building, hot reload, and plugin configuration

octave-commons☆ 1 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

What I do

  • Set up Vite projects with React and TypeScript
  • Configure Vite plugins and optimization options
  • Run dev server with hot module replacement
  • Build production bundles and analyze output
  • Configure proxy settings for backend APIs
  • Debug build issues and dependency conflicts

When to use me

Use me when working with Vite-based frontend projects, especially when:

  • Setting up new Vite projects or configurations
  • Configuring dev server and proxy settings
  • Building and optimizing production bundles
  • Debugging HMR or build issues
  • Adding Vite plugins

Common commands

  • npm run dev - Start dev server (default port 5173)
  • npm run build - Build for production
  • npm run preview - Preview production build locally
  • vite optimize - Pre-bundle dependencies
  • vite --debug - Run with debug output

Configuration patterns

  • server.port - Change dev server port
  • server.proxy - Proxy backend requests (e.g., {"/api": "http://localhost:3000"})
  • build.outDir - Output directory (default: dist)
  • plugins - Add plugins (e.g., @vitejs/plugin-react)

TypeScript integration

  • Enable strict mode in tsconfig.json
  • Use Vite's tsconfig.paths support
  • Type-check with tsc --noEmit before building
  • Import with .js extensions (Vite transpiles)

Environment variables

  • Load from .env, .env.local, .env.production
  • Access via import.meta.env.VARIABLE_NAME
  • Prefix with VITE_ for client-side variables

Performance tips

  • Lazy load routes and components
  • Use dynamic imports for code splitting
  • Configure build.chunkSizeWarningLimit for large bundles
  • Analyze bundle size with rollup-plugin-visualizer

HMR troubleshooting

  • Check console for HMR connection errors
  • Verify vite.config.ts exports default config
  • Ensure file watchers work (increase limit on Linux)
  • Restart dev server if HMR fails repeatedly

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!