|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +**weapp-tailwindcss** is a Turbo-based monorepo that brings TailwindCSS atomic styling to mini-program (小程序) developers. It provides comprehensive TailwindCSS support for WeChat Mini Programs, Taro, uni-app, remax, rax, mpx, and other mini-program frameworks across webpack, vite, rspack, rollup, rolldown, and gulp build tools. |
| 8 | + |
| 9 | +## Monorepo Structure |
| 10 | + |
| 11 | +- **packages/** - Core packages including: |
| 12 | + - `weapp-tailwindcss` - Main package with CLI (`weapp-tailwindcss` or `weapp-tw`) |
| 13 | + - `@weapp-tailwindcss/shared` - Shared utilities |
| 14 | + - `@weapp-tailwindcss/postcss` - PostCSS plugin |
| 15 | + - `@weapp-tailwindcss/babel` - Babel transformations |
| 16 | + - `@weapp-tailwindcss/logger` - Logging utilities |
| 17 | + - `tailwindcss-injector`, `tailwindcss-core-plugins-extractor`, `tailwindcss-config` - Build tool integrations |
| 18 | + |
| 19 | +- **packages-runtime/** - Runtime-specific implementations (vite, webpack integrations) |
| 20 | + |
| 21 | +- **apps/** - Example applications (react-app, vue-app, native, taro-app, vite-native) |
| 22 | + |
| 23 | +- **demo/** - Framework-specific demo projects (native, taro, uni-app, rax, mpx, gulp) |
| 24 | + |
| 25 | +- **templates/** - Project templates for different frameworks |
| 26 | + |
| 27 | +- **website/** - Documentation website |
| 28 | + |
| 29 | +- **benchmark/** - Performance benchmarking tools |
| 30 | + |
| 31 | +- **e2e/** - End-to-end tests with CSS snapshot testing |
| 32 | + |
| 33 | +## Common Development Commands |
| 34 | + |
| 35 | +### Build |
| 36 | +```bash |
| 37 | +pnpm build # Build all packages (uses turbo cache) |
| 38 | +pnpm build:nocache # Build without cache (TURBO_FORCE=1) |
| 39 | +pnpm build:apps # Build apps only |
| 40 | +pnpm build:pkgs # Build packages only |
| 41 | +pnpm build:docs # Build documentation website |
| 42 | +pnpm build:demo # Build demo apps |
| 43 | +``` |
| 44 | + |
| 45 | +### Test |
| 46 | +```bash |
| 47 | +pnpm test # Run all tests (vitest) |
| 48 | +pnpm test:dev # Run tests in watch mode |
| 49 | +pnpm test:core # Run main package tests |
| 50 | +pnpm test:plugins # Run plugin package tests |
| 51 | +pnpm test:typography # Run typography tests |
| 52 | +pnpm test:ui # Run tests with UI |
| 53 | +pnpm e2e # Run end-to-end tests |
| 54 | +pnpm e2e:u # Update e2e snapshots |
| 55 | +pnpm bench # Run benchmarks |
| 56 | +``` |
| 57 | + |
| 58 | +### Development |
| 59 | +```bash |
| 60 | +pnpm dev:apps # Run all apps in development mode |
| 61 | +pnpm format # Format code with prettier |
| 62 | +pnpm lint # Lint code |
| 63 | +pnpm lint:fix # Fix linting issues |
| 64 | +``` |
| 65 | + |
| 66 | +### Release |
| 67 | +```bash |
| 68 | +pnpm release # Create changeset |
| 69 | +pnpm pr # Enter alpha prerelease mode |
| 70 | +pnpm pr:beta # Enter beta prerelease mode |
| 71 | +pnpm pr:exit # Exit prerelease mode |
| 72 | +pnpm publish-packages # Build, test, version, and publish |
| 73 | +``` |
| 74 | + |
| 75 | +### Demo Management |
| 76 | +```bash |
| 77 | +pnpm demo:install # Install dependencies for demos |
| 78 | +pnpm demo:install:beta # Install beta versions for demos |
| 79 | +pnpm demo:install:alpha # Install alpha versions for demos |
| 80 | +``` |
| 81 | + |
| 82 | +## Architecture Notes |
| 83 | + |
| 84 | +### Package Entry Points |
| 85 | +The main `weapp-tailwindcss` package exports multiple entry points for different use cases: |
| 86 | +- Default: webpack/vite plugin |
| 87 | +- `./webpack4`: PostCSS 7 + webpack 4 compatibility |
| 88 | +- `./vite`, `./webpack`, `./gulp`, `./core`: Build-specific integrations |
| 89 | +- `./escape`, `./types`, `./defaults`, `./presets`: Utilities |
| 90 | +- CSS exports: `./preflight.css`, `./theme.css`, `./utilities.css`, `./uni-app-x.css` |
| 91 | + |
| 92 | +### Turbo Build System |
| 93 | +- Uses turbo for task orchestration and caching |
| 94 | +- Build dependencies are defined in `turbo.json` |
| 95 | +- `packages/*` and `packages-runtime/*` must build before `apps/*` and `demo/*` |
| 96 | + |
| 97 | +### Workspace Dependencies |
| 98 | +- Uses pnpm workspaces with `catalog:` for centralized dependency versioning (see `pnpm-workspace.yaml`) |
| 99 | +- Internal packages reference each other with `workspace:*` |
| 100 | + |
| 101 | +### Testing Architecture |
| 102 | +- Root `vitest.config.ts` dynamically discovers all package vitest configs from workspace |
| 103 | +- E2E tests use CSS snapshot testing (`e2e/update-snapshots` script syncs snapshots) |
| 104 | + |
| 105 | +### Node.js Requirements |
| 106 | +- Root package requires `node >= 18.0.0` |
| 107 | +- Main `weapp-tailwindcss` package requires `node ^18.17.0 || >=20.5.0` |
| 108 | +- Package manager: [email protected] |
| 109 | + |
| 110 | +### TailwindCSS Version Support |
| 111 | +- Supports TailwindCSS v4, v3, and v2 JIT |
| 112 | +- Different entry points handle different TailwindCSS versions |
| 113 | + |
| 114 | +## CLI Tool |
| 115 | +The package provides a CLI via `bin/weapp-tailwindcss.js`: |
| 116 | +```bash |
| 117 | +weapp-tailwindcss patch # Patch TailwindCSS for mini-program compatibility |
| 118 | +weapp-tw patch # Shorthand alias |
| 119 | +``` |
| 120 | + |
| 121 | +## Special Conventions |
| 122 | +- ES modules throughout (`type: "module"`) |
| 123 | +- TypeScript strict mode |
| 124 | +- Changesets for version management |
| 125 | +- Commitlint enforces conventional commits |
| 126 | +- Primary documentation is in Chinese (tw.icebreaker.top) |
0 commit comments