About weapp-vite-best-practices
weapp-vite-best-practices is a project-level guide to configuring and operating weapp-vite, for developers maintaining these projects. It starts with stable defaults and covers routing, build structure, CLI command ownership, troubleshooting, and alignment of AI workflows with project documentation.
Key features
- 01Organize Vite and mini-program configuration
- 02Configure routing and component auto-import
- 03Set up subpackages, npm, and workers
- 04Separate build-tool and IDE CLI commands
- 05Troubleshoot paths, types, and routing
- 06Align AGENTS.md, docs, and MCP
Use cases
- 01Diagnose build output or routing issues
- 02Configure subpackages and multi-platform capabilities
- 03Clarify ownership of preview and upload commands
- 04Align AI debugging entry points and project docs
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ weapp-vite/ weapp-vite --skill weapp-vite-best-practicesAfter installing, type/weapp-vite-best-practicesin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/cli-dispatch-playbook.mdconfig-playbook.mddebug-playbook.mdide-command-playbook.mdide-i18n-config-playbook.mdDetails
From the project READMEweapp-vite-best-practices
用途
用稳定默认值先把 weapp-vite 项目跑顺,再按目标逐步接入分包、AI、Web runtime、库模式和性能优化。
何时使用
- 用户要配置
vite.config.ts里的weapp。 - 用户要排查输出缺页、路径不对、自动路由不生效、layout 不生效。
- 用户要接入分包、npm 落位、多平台、worker、web runtime、lib mode。
- 用户要让 AI 正确使用项目,包括
AGENTS.md、dist/docs、screenshot / compare / logs / mcp。 - 用户要梳理
weapp-vite与weapp-ide-cli的命令归属、透传边界、preview/upload/open/config这类 DevTools CLI 能力。
不适用场景
本 skill 聚焦项目级架构、CLI 所有权、构建编排和 AI 工作流对齐。
.vue宏和模板兼容:使用weapp-vite-vue-sfc-best-practices。wevu生命周期、状态和事件:使用wevu-best-practices。- 原生迁移:使用
native-to-weapp-vite-wevu-migration。
核心流程
- 先收集上下文:
vite.config.tsapp.json/app.json.ts- 分包、组件、页面目录
- package scripts
- 根
AGENTS.md - 本地
node_modules/weapp-vite/dist/docs/
- 区分顶层 Vite 字段和小程序专属
weapp.*,先理顺基础项:weapp.srcRootweapp.platformweapp.multiPlatformweapp.autoRoutesweapp.autoImportComponentsweapp.routeRulesweapp.typescript
- 按目标启用能力:
- AI / 调试:
weapp.forwardConsole、weapp.mcp、wv screenshot、wv compare、wv ide logs --open - 产物与结构:
subPackages、npm、chunks、worker - 进阶链路:
web、lib
- AI / 调试:
- CLI 与 IDE 所有权保持清晰:
weapp-vite原生命令优先weapp-ide-cli只在 catalog 命中后透传preview/upload/open/config/screenshot/compare的帮助、退出码、JSON 输出要稳定- 不要让未知命令盲目 passthrough
- 常见症状先分诊:
- 输出路径不对:查
srcRoot、project config、build.outDir .weapp-vite类型异常:先跑wv prepare- 页面 / layout 不对:查
autoRoutes、routeRules、definePageMeta - 自动导入异常:查
autoImportComponents与 resolver - AI 无法稳定操作:查
AGENTS.md、dist/docs、CLI 路由、MCP
- 输出路径不对:查
- 验证按最小范围进行;若改了
packages/*/src/**,下游验证前先重建对应包,并明确dist sync: rebuilt weapp-vite before downstream validation。
约束
- 不要在
srcRoot和页面来源没确认前先调 chunk 策略。 - 不要把 Web runtime 当作小程序真机等价运行时。
- 不要忽略
AGENTS.md和dist/docs,它们是当前 AI 合约的一部分。 - 不要让
weapp-vite和weapp-ide-cli命令名单分裂。 - 不要让
screenshot/compare/ide logs的文件和 JSON 合约漂移。
输出
应用本 skill 时,输出必须包含:
- 诊断摘要。
- 最小改动列表。
- 推荐验证命令。
- 分包 / chunk / AI 工作流的取舍说明。
完成标记
weapp配置结构清晰。- 路由和组件来源明确。
.weapp-vite支持文件流程已考虑。- CLI 原生命令、IDE 透传和 AI 路由不冲突。
AGENTS.md、dist/docs、MCP、截图和日志入口保持一致。
参考资料
references/config-playbook.mdreferences/debug-playbook.mdreferences/cli-dispatch-playbook.mdreferences/ide-command-playbook.mdreferences/ide-i18n-config-playbook.md
Comments
Markdown supported