React + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel (or oxc when used in rolldown-vite) for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
Expanding the ESLint configuration
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the TS template for information on how to integrate TypeScript and typescript-eslint in your project.
环境变量配置
本项目使用环境变量来配置 API 基础地址。
配置说明
-
复制
.env.example文件为.env:cp .env.example .env -
编辑
.env文件,设置您的 API 基础地址:VITE_API_BASE_URL=http://your-api-server.com/api -
环境变量以
VITE_开头才能在客户端代码中访问
可用环境变量
VITE_API_BASE_URL: API 服务器的基础地址
开发说明
- 环境变量在开发服务器重启后生效
- 生产环境部署时,请确保正确设置环境变量