Nx is a powerful build system with first-class monorepo support. It provides computation caching, affected commands, code generation, and project graph visualization — all for free.
Getting Started
npx create-nx-workspace@latest my-workspace --preset=ts
cd my-workspace
Project Configuration
// project.json
{
"name": "my-app",
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/my-app",
"main": "apps/my-app/src/main.ts"
}
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/my-app/jest.config.ts"
}
}
}
}
Affected Commands
# Only build/test what changed
nx affected -t build
nx affected -t test
nx affected -t lint
# See what's affected
nx affected --graph
Code Generation
# Generate a new library
nx g @nx/js:lib shared-utils
# Generate a React component
nx g @nx/react:component Button --project=ui-lib
# Generate a new app
nx g @nx/next:app my-next-app
Task Caching and Distribution
// nx.json
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"]
}
}
}
}
Project Graph
# Interactive project dependency graph
nx graph
# Focus on specific project
nx graph --focus=my-app
Nx Plugins Ecosystem
Nx has plugins for React, Angular, Next.js, Nest, Express, Storybook, Cypress, Jest, ESLint, and more. Each plugin provides generators and executors tailored to the framework.
Need to extract or automate web content at scale? Check out my web scraping tools on Apify — no coding required. Or email me at spinov001@gmail.com for custom solutions.
Top comments (0)