Angular is a framework for building web applications. Nx has first party support for Angular projects. If you're familiar with the Angular CLI, ng, then Nx CLI will feel very familiar. The @nx/angular plugin adds generators, Angular CLI builder integration (executors) and migrations so you can run Angular tasks through Nx. With Nx, each project has its own configuration instead of a single angular.json file, making it more scalable for monorepos. You can use Angular with Nx without the plugin and still get task caching, task orchestration, and the project graph.
See the Nx and Angular versions matrix to know which Nx version supports a given Angular version.
Add to an existing workspace
Section titled “Add to an existing workspace”nx add @nx/angularVerify the plugin is active by inspecting an Angular project:
nx show project <your-app-name>Look for build, serve, test, lint, or e2e targets generated from angular.json.
Create a new workspace
Section titled “Create a new workspace”npx create-nx-workspace my-org --template=nrwl/angular-templateLocal Development
Section titled “Local Development”Generate an Angular Application
Section titled “Generate an Angular Application”nx g @nx/angular:app apps/my-appBy default, Nx configures ESLint for linting, Jest for unit tests, and Cypress for e2e tests. Read more of the options available for the application generator in the Angular application generators reference.
nx serve my-appnx build my-appnx test my-appnx lint my-appnx e2e my-appGenerate an Angular Library
Section titled “Generate an Angular Library”nx g @nx/angular:lib libs/my-libBy default, Nx configures ESLint for linting, Jest for unit tests. Read more of the options available for the application generator in the angular library generators reference.
There are also generators for setting up common items inside your projects, such as components and services:
nx g @nx/angular:component libs/my-lib/src/lib/my-componentnx g @nx/angular:service libs/my-lib/src/lib/my-servicenx test my-libnx lint my-libBuildable and Publishable Libraries
Section titled “Buildable and Publishable Libraries”If you need libraries that build or publish, generate them with build output enabled and an import path. This creates build targets you can cache and run in CI. See Set up incremental builds for Angular libraries for details.
nx g @nx/angular:lib libs/my-libSet Up Module Federation
Section titled “Set Up Module Federation”Nx includes generators for scaffolding Module Federation architectures with Angular. Generate a host application and its remotes in one command:
nx g @nx/angular:host apps/shell --remotes=products,checkoutSee all options in the Angular host generators reference.
Add a remote to an existing host:
nx g @nx/angular:remote apps/login --host=shellSee all options in the Angular remote generators reference.
Pass --dynamic for dynamic federation (remotes resolved at runtime) or --ssr for server-side rendering with Module Federation.
CI Considerations
Section titled “CI Considerations”Run only what changed using the project graph:
nx affected -t build test lint e2eEnable remote caching for faster CI runs:
nx connectIf you use Angular CLI configurations, define a ci configuration in angular.json and run tasks with --configuration=ci for CI-specific settings.
See Set Up CI for a sample CI setup.