How ant-design/ant-design-mobile works
Project Type and Purpose
• This is an open‑source, atomic React component library (“Ant Design Mobile”) that provides UI building blocks for mobile web apps.
• It includes:
• A source tree of >100 components (src/components) with TSX + LESS + demos + tests
• A utilities layer (src/utils)
• A documentation site powered by Dumi (docs/, .dumi/)
• Build and publishing scripts (gulpfile.js, babel‑transform‑less‑to‑css.js, package.json scripts)
• CI/CD pipelines (GitHub Actions workflows under .github/workflows)
Top‑Level Architecture
• Source Components
• React + TypeScript component definitions (src/components/*)
• Style assets (LESS files, CSS‑variable theming in src/global, config/style variables)
• Demos and Markdown API docs (index.en.md/index.zh.md)
• Unit tests (Jest snapshots and test files)
• Utilities
• Generic helper functions and hooks (src/utils, src/hooks)
• Shared TypeScript typings (src/typings)
• Documentation Site (Dumi)
• Configuration (config/config.ts, config/components.ts, config/menus.tsx, config/navs.ts)
• Theme and plugins (.dumi/theme, .dumi/plugin‑*)
• Markdown content under docs/
• Build & Packaging
• Babel transforms and PostCSS (babel‑transform‑less‑to‑css.js, scripts/postcss‑disable‑css‑vars.js)
• Rollup/Gulp entrypoints (gulpfile.js, fileTransformer.js)
• Outputs: ES modules, CommonJS, UMD bundle (umd.html, dist/* via npm publish)
• Testing & Quality
• Jest configuration (jest.config.js)
• Linting (ESLint, Stylelint, Prettier)
• Commit hooks (Husky)
• CI/CD & External Services
• GitHub Actions (CI, code coverage, doc deploy)
• npm registry (package publish)
• Codecov, size‑limit, jsDelivr
1. Source Components
• src/components (atomic UI modules)
2. Utilities & Hooks
• src/utils & src/hooks
3. Styling & Theming
• LESS variables, CSS vars (src/global, config style)
4. Documentation Generator
• Dumi engine (.dumi/, docs/) + config/
5. Build Pipeline
• Babel, Gulp, Rollup, PostCSS, fileTransformer.js
6. Testing & Linting
• Jest, ESLint, Stylelint, Husky hooks
7. CI/CD
• GitHub Actions workflows
8. Publish Targets
• npm package (ESM/CJS), UMD bundle, static docs site
• Components + Utilities + Styling → Build Pipeline → Dist Artifacts → npm registry
• Components + Markdown docs → Dumi → Static Site → Docs Hosting
• Source Components → Jest → Test Reports / Codecov
• Commit → Husky → Pre‑commit Hooks → Lint + Test
• Push to GitHub → GitHub Actions → CI (Lint, Test, Build) → Publish / Deploy
c. Architectural Patterns
• Atomic Component Pattern: 1 folder per component, consistent interface + style + tests
• Plugin‑based Docs: Dumi with custom theme/plugins to generate MDX + React previews
• Theming via CSS Variables: Global LESS variables patched at build time
• Mono‑repo–style toolchain: Central config for build, lint, test, docs
d. Key Technologies & Frameworks
• React + TypeScript
• LESS + PostCSS + CSS‑variables
• Dumi (documentation tool)
• Babel & Gulp/Rollup (build)
• Jest (unit testing)
• ESLint, Stylelint, Prettier, Husky (code quality)
• GitHub Actions (CI/CD)
Essential Elements
• Component library core (source + style)
• Build pipeline and output targets
• Documentation site generation
• Testing and code quality steps
• CI/CD integration and publishing