npx skills add https://github.com/mindrally/skills --skill nx您是一位 Nx 专家,Nx 是一个智能、快速且可扩展的单体仓库构建系统。
apps/ - 应用程序项目(Web 应用、API、移动应用)libs/ - 库项目(共享代码、功能、工具)scope-type-name(例如:shared-ui-button)配置 nx.json 以设置工作区范围的设置:
{
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"cache": true
},
"test": {
"cache": true
}
},
"defaultBase": "main"
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
project.jsontags 以强制执行模块边界每个项目都应有一个 project.json:
{
"name": "my-app",
"sourceRoot": "apps/my-app/src",
"projectType": "application",
"tags": ["scope:web", "type:app"],
"targets": {
"build": { },
"serve": { },
"test": { }
}
}
application 或 librarynx g @nx/react:app my-app - 生成 React 应用程序nx g @nx/react:lib my-lib - 生成 React 库nx g @nx/react:component my-component --project=my-lib - 生成组件--dry-run 在执行前预览更改使用 ESLint 规则强制执行边界:
{
"@nx/enforce-module-boundaries": [
"error",
{
"depConstraints": [
{ "sourceTag": "type:app", "onlyDependOnLibsWithTags": ["type:lib", "type:util"] },
{ "sourceTag": "type:lib", "onlyDependOnLibsWithTags": ["type:lib", "type:util"] },
{ "sourceTag": "scope:web", "onlyDependOnLibsWithTags": ["scope:web", "scope:shared"] }
]
}
]
}
nx affected:buildnx affected:testnx affected:lintinputs 和 outputsnx build my-app - 构建特定项目nx run-many -t build - 构建所有项目nx affected -t test - 测试受影响的项目nx affected:test 进行高效的测试运行- uses: nrwl/nx-set-shas@v4
- run: nx affected -t lint test build
nx-cloud record 捕获指标index.ts)实现简洁的导入nx graph每周安装量
101
仓库
GitHub 星标数
43
首次出现
2026年1月25日
安全审计
安装于
opencode80
gemini-cli78
cursor73
codex73
claude-code70
github-copilot69
You are an expert in Nx, the smart, fast, and extensible build system for monorepos.
apps/ - Application projects (web apps, APIs, mobile apps)libs/ - Library projects (shared code, features, utilities)scope-type-name (e.g., shared-ui-button)Configure nx.json for workspace-wide settings:
{
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"cache": true
},
"test": {
"cache": true
}
},
"defaultBase": "main"
}
project.json for project-specific configurationtags for enforcing module boundariesEach project should have a project.json:
{
"name": "my-app",
"sourceRoot": "apps/my-app/src",
"projectType": "application",
"tags": ["scope:web", "type:app"],
"targets": {
"build": { },
"serve": { },
"test": { }
}
}
application or librarynx g @nx/react:app my-app - Generate React applicationnx g @nx/react:lib my-lib - Generate React librarynx g @nx/react:component my-component --project=my-lib - Generate component--dry-run to preview changes before executionEnforce boundaries using ESLint rules:
{
"@nx/enforce-module-boundaries": [
"error",
{
"depConstraints": [
{ "sourceTag": "type:app", "onlyDependOnLibsWithTags": ["type:lib", "type:util"] },
{ "sourceTag": "type:lib", "onlyDependOnLibsWithTags": ["type:lib", "type:util"] },
{ "sourceTag": "scope:web", "onlyDependOnLibsWithTags": ["scope:web", "scope:shared"] }
]
}
]
}
nx affected:buildnx affected:testnx affected:lintinputs and outputs for accurate cachingnx build my-app - Build specific projectnx run-many -t build - Build all projectsnx affected -t test - Test affected projectsnx affected:test in CI for efficient test runsUse Nx Cloud for distributed task execution
Configure GitHub Actions with Nx:
- uses: nrwl/nx-set-shas@v4
- run: nx affected -t lint test build
Implement proper caching strategies
Use nx-cloud record for capturing metrics
index.ts) for clean importsnx graphWeekly Installs
101
Repository
GitHub Stars
43
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode80
gemini-cli78
cursor73
codex73
claude-code70
github-copilot69
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
116,600 周安装