Skip to content

Latest commit

ย 

History

History
190 lines (147 loc) ยท 7.97 KB

File metadata and controls

190 lines (147 loc) ยท 7.97 KB

React Seed

An out-of-the-box React frontend template

Stars License npm downloads Version AtomGit Stars

็ฎ€ไฝ“ไธญๆ–‡ English

๐Ÿ”— Demo

๐Ÿช… Related Versions

โœจ Features

  • ๐Ÿ“ฆ Out of the box, no extra configuration required
  • ๐Ÿ“ Key modules are well-commented for low learning cost
  • ๐Ÿš€ Fast startup and compilation
  • ๐ŸŒฑ Easy to customize and extend
  • ๐Ÿ›ก๏ธ Strict code conventions

๐Ÿš€ Tech Stack

Category Stack Version
Framework React + ReactDOM 19.x
Language TypeScript 5.x
Build Vite + @vitejs/plugin-react 8.x
Routing react-router 7.x
State MobX + mobx-react-lite 6.x / 4.x
Request axios + axios-retry 1.x
Style Less + CSS Modules + PostCSS โ€”
Icon @phosphor-icons/react + local svg as React component (vite-plugin-svgr) โ€”
Convention ESLint 9 (flat config) + Prettier + Stylelint + husky + lint-staged + commitlint โ€”

โŒ›๏ธ Requirements

  • Node โ‰ฅ 22.22.1 (CI pinned to 22.22.3 via volta)
  • npm โ‰ฅ 7.0.0 / yarn โ‰ฅ 1.22.4 / pnpm โ€” pick one

๐Ÿƒ Quick Start

# 1. Install dependencies (pick one)
npm install
# or
yarn install

# 2. Start dev server
npm run start

๐Ÿ“ฆ Build

npm run build:qa     # build for testing environment
npm run build:prod   # build for production
npm run deploy       # build and publish via gh-pages
npm run clean        # clean node_modules

๐Ÿ“‚ Project Structure

react-seed/
โ”œโ”€โ”€ vite.config.ts           # Vite build config (alias / plugins / build / server)
โ”œโ”€โ”€ index.html               # HTML entry template (Vite root)
โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ favicon.ico          # Static assets (copied as-is to build output)
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.tsx            # App mount entry
โ”‚   โ”œโ”€โ”€ App.tsx              # Root component + useRoutes
โ”‚   โ”œโ”€โ”€ vite-env.d.ts        # Vite types & import.meta.env declarations
โ”‚   โ”œโ”€โ”€ router/              # Centralized routes (React.lazy + SuspenseLazy)
โ”‚   โ”œโ”€โ”€ api/                 # API layer (axios wrapper, grouped by page)
โ”‚   โ”œโ”€โ”€ store/               # MobX stores
โ”‚   โ”œโ”€โ”€ components/          # Common components (barrel exports)
โ”‚   โ”œโ”€โ”€ view/                # Page-level components
โ”‚   โ”œโ”€โ”€ constants/           # Constants / enums
โ”‚   โ”œโ”€โ”€ interface/           # Business type definitions
โ”‚   โ”œโ”€โ”€ types/               # Global .d.ts
โ”‚   โ”œโ”€โ”€ utils/               # Utilities + custom hooks
โ”‚   โ”œโ”€โ”€ assets/              # Static assets (incl. svg sprite)
โ”‚   โ””โ”€โ”€ styles/index.less    # Global styles
โ”œโ”€โ”€ docs/                    # Design materials, UI references, English README
โ”œโ”€โ”€ .env.development         # Development env variables
โ”œโ”€โ”€ .env.qa                  # QA env variables
โ”œโ”€โ”€ .env.production          # Production env variables
โ”œโ”€โ”€ eslint.config.mjs        # ESLint 9 flat config
โ”œโ”€โ”€ tsconfig.json            # TS config (with path alias)
โ”œโ”€โ”€ AGENTS.md                # Project guide for AI coding assistants
โ””โ”€โ”€ package.json

๐Ÿ›  Development Guide

Path Alias

Defined in both tsconfig.json and vite.config.ts โ€” prefer alias over relative paths:

import {Button} from '@/components';
import {useStores} from '@/store';

Add a Page

  1. Create index.tsx + index.less under src/view/XxxPage/
  2. Register a lazy-loaded route via SuspenseLazy in src/router/index.tsx
  3. Edit src/view/Tab/index.tsx if a top-nav entry is needed

Add an API

  1. Create index.ts and types/<page-name>.ts under src/api/<page-name>/
  2. Import the wrapped request from ../request, call request<ResponseT>({url, method, data})
  3. Keep request/response types co-located in the same types/

State Management (MobX)

  • Call makeAutoObservable(this) in store constructors; wrap async assignments with runInAction(...)
  • Register new stores in stores of src/store/index.ts
  • Components reading observables must be wrapped with observer

For more conventions and AI collaboration notes, see AGENTS.md.

๐Ÿ“ Commit Convention

Commit messages follow commitlint:

git commit -m "<type>: <emoji> <subject>"
# example
git commit -m "feat: โœจ Add order query page"

Common types:

type emoji description
feat โœจ New feature
fix ๐Ÿ› Bug fix
docs ๐Ÿ“ Documentation changes
style ๐Ÿ’„ Style adjustments (no logic impact)
refactor ๐Ÿ”จ Refactor (no new feature, no bug fix)
perf โšก Performance optimization
build ๐Ÿ“ฆ Build system or dependency changes
config ๐Ÿ”ง Configuration changes
chore ๐Ÿ”ฅ Miscellaneous
release ๐Ÿ”– Release a version

๐Ÿท Branches

Branch Description
main Main branch
dev Development branch
deploy Demo deploy branch

๐Ÿ“š References

๐Ÿค Contributing

  • ๐Ÿ“ฌ Feel free to open Issues
  • ๐Ÿง™โ€โ™€๏ธ Pull Requests are welcome โ€” see how to contribute
  • ๐Ÿฑ If this project helps you, why not treat the developer's cat to a can of food โ€” cats are the real fuel that keeps this project running: Sponsor the project

๐Ÿ’ก License

The code and documentation of this project are released under the MIT License.