3.3 KiB
3.3 KiB
AGENTS.md
You are an expert in JavaScript, Rsbuild, and web application development. You write maintainable, performant, and accessible code.
Tech Stack
- React 19 + TypeScript — frontend framework and type system
- Rsbuild 2 — build tool (wraps Rspack), configured in
rsbuild.config.ts - React Router v7 (
react-router) — client-side routing - antd 6 + @ant-design/icons 6 — UI component library and icon set
- pnpm — package manager
Commands
pnpm run dev- Start the dev server (auto-opens http://localhost:3000)pnpm run build- Build the app for production (output:dist/)pnpm run preview- Preview the production build locallypnpm run lint- Lint TypeScript/TSX files with ESLintpnpm run format- Format all files with Prettier
Project Structure
src/
index.tsx # App entry point — mounts React root to #root
App.tsx # Root component — renders <RouterProvider>
App.css # Root component styles
router.tsx # createBrowserRouter,由 routes 树自动生成
env.d.ts # Rsbuild environment type declarations
routes/
types.ts # RouteItem 类型定义
index.tsx # 路由树数据(唯一数据源),导出 routes / RouteItem
utils.tsx # toRouteObjects():将路由树转为 React Router RouteObject[]
layouts/
RootLayout.tsx # Root layout with nav links and <Outlet />
pages/
Home.tsx # "/" index page
About.tsx # "/about" page
NotFound.tsx # "*" catch-all 404 page
public/
favicon.png
rsbuild.config.ts # Build configuration
eslint.config.mjs # ESLint flat config (TS/TSX only, dist/ ignored)
tsconfig.json
Routing
Uses React Router v7 (react-router) with createBrowserRouter.
- 唯一数据源:
src/routes/index.tsx维护routes: RouteItem[]路由树 RouteItem字段:path/label/icon?/component?/hideInMenu?/redirect?/children?toRouteObjects(routes)将路由树转换为 React Router 所需的RouteObject[]- 菜单、面包屑等模块直接消费
routes数组,无需重复维护路由信息 - 添加新页面:在
src/pages/创建组件,在src/routes/index.tsx追加节点即可
TypeScript Configuration
noUnusedLocalsandnoUnusedParametersare enabled — unused variables/parameters are errorsverbatimModuleSyntaxis enabled — type-only imports must useimport typemoduleResolution: "bundler"— use bundler-style module resolution
Code Style
- Single quotes (
singleQuote: truein.prettierrc) - ESLint applies to
**/*.{ts,tsx}only, withreact-hooksandreact-refreshplugins enabled
UI Components (antd)
- Import components directly from
antd, icons from@ant-design/icons— tree-shaking is automatic - To customize the theme, wrap the app with
ConfigProviderinApp.tsx:import { ConfigProvider } from 'antd'; <ConfigProvider theme={{ token: { colorPrimary: '#00b96b' } }}> <RouterProvider router={router} /> </ConfigProvider>
Docs
- Rsbuild: https://rsbuild.rs/llms.txt
- Rspack: https://rspack.rs/llms.txt
- antd v6 完整文档(中文): https://ant.design/llms-full-cn.txt
- antd v6 组件单页(中文): https://ant.design/components/{组件名}-cn.md(如 button-cn.md)