weapp-vite-best-practices
17
总安装量
16
周安装量
#20051
全站排名
安装命令
npx skills add https://github.com/weapp-vite/weapp-vite --skill weapp-vite-best-practices
Agent 安装分布
github-copilot
15
codex
15
kimi-cli
15
gemini-cli
15
amp
15
cursor
15
Skill 文档
weapp-vite-best-practices
Purpose
Build or refactor weapp-vite projects with stable defaults first, then optimize packaging and performance. Prioritize predictable output and reproducible CI.
Trigger Signals
- User asks about
vite.config.ts+weappconfig design. - User asks how to organize pages/components/subpackages in weapp-vite.
- User reports build output problems: missing pages/components, wrong output root, route generation mismatch, chunk duplication.
- User asks about CI automation with WeChat DevTools or
weapp-ide-cli. - User asks when to use
autoRoutes, auto-imported components, or chunk shared strategy.
Scope Boundary
Use this skill when the core issue is project-level architecture or build orchestration.
Do not use this as the primary skill when:
- The issue is mainly Vue SFC template/macro syntax. Use
weapp-vite-vue-sfc-best-practices. - The issue is mainly runtime lifecycle/state/store patterns. Use
wevu-best-practices. - The task is native mini-program to weapp-vite migration planning. Use
native-to-weapp-vite-wevu-migration.
Quick Start
- Confirm baseline runtime and source roots.
- Classify goal: new setup, refactor, debug, or performance optimization.
- Apply minimum viable config changes in
vite.config.tsand app/page JSON sources. - Verify with targeted build/type checks before suggesting broader cleanup.
Execution Protocol
- Gather context first
- Inspect
vite.config.ts,app.jsonsource strategy, pages/subpackages layout, and scripts. - Confirm
weapp.srcRootand expected output root. - Ask for missing constraints only when blocked (target platform, package limits, CI environment).
- Build a minimal strategy
- Keep config layering explicit: generic Vite config vs mini-program-specific
weappsection. - Prefer convention-first setup (
autoRoutes, auto components) and add overrides only when required. - Choose subpackage mode intentionally:
normal subpackagefor shared context.independent subpackageonly when strict isolation is necessary.
- Choose
weapp.chunks.sharedStrategyby explicit goal:duplicatefor better subpackage first-open performance.hoistfor stronger deduplication and package-size control.
- Diagnose by symptom category
- Output missing/wrong path: verify
srcRoot, route generation source, and glob coverage. - Slow build: inspect plugin timing and high-cost transforms.
- Route/component generation mismatch: verify generated artifacts and resolver behavior.
- Propose actionable edits
- Give concrete file-level changes with rationale and expected impact.
- Avoid broad config rewrites when a local fix can solve the issue.
- Verify narrowly
- Prefer targeted checks, for example:
pnpm build:pkgs
pnpm vitest run <related-test-file>
- Only suggest full regression when change scope requires it.
Guardrails
- Do not optimize chunk strategy before
srcRootand route generation are confirmed. - Do not combine many advanced overrides in the first iteration.
- Do not assume web-only conventions; keep mini-program JSON semantics explicit.
- Do not mix architecture refactor with unrelated business logic changes.
Output Contract
When applying this skill, return:
- A short diagnosis summary.
- A minimal change list with concrete file targets.
- Suggested verification commands (narrow first, then broad if needed).
- Tradeoff notes for subpackage/chunk choices.
Completion Checklist
vite.config.tshas a clear and minimalweappsection.pages/subPackagessource-of-truth is explicit (manual or auto routes).- Component registration strategy is deterministic (auto import + resolver policy).
- Subpackage/chunk strategy is selected with stated reason.
- Dev/CI workflow is reproducible and not dependent on manual IDE clicks.
References
references/config-playbook.mdreferences/debug-playbook.md