可快速搭建 React 前端开发环境,支持 HMR 和 ESLint 规则,提供两种官方插件选择,可按需扩展 ESLint 配置以适应生产环境需求。【此简介由AI生成】
| Files | Last commit | Last update |
|---|---|---|
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago |
Translated by AI, submit an issue feedback
React + TypeScript + Vite
本模板提供了最简化的设置,以便在 Vite 中使用 React 并启用 HMR(热模块替换)及部分 ESLint 规则。
目前,有两个官方插件可供使用:
- @vitejs/plugin-react 使用 Babel(或在 rolldown-vite 中使用时采用 oxc)实现快速刷新
- @vitejs/plugin-react-swc 使用 SWC 实现快速刷新
React 编译器
由于 React 编译器会影响开发和构建性能,因此本模板未启用该功能。如需添加,请参阅 此文档。
扩展 ESLint 配置
如果您正在开发生产级应用,建议更新配置以启用类型感知的 lint 规则:
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
你也可以安装 eslint-plugin-react-x 和 eslint-plugin-react-dom 来获取 React 特定的 lint 规则:
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
Introduction
可快速搭建 React 前端开发环境,支持 HMR 和 ESLint 规则,提供两种官方插件选择,可按需扩展 ESLint 配置以适应生产环境需求。【此简介由AI生成】
Customize your domain