Nx Monorepo

Nx Monorepo

Table of Contents

Nx

Monorepos and Fast CI

Build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.

Documentation:

Getting started:

npx create-nx-workspace

Output of running this:

Need to install the following packages:
create-nx-workspace@20.3.0
Ok to proceed? (y) y

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · hello-nx
✔ Which stack do you want to use? · react
✔ What framework would you like to use? · nextjs
✔ Integrated monorepo, or standalone project? · integrated
✔ Application name · hello-nx-client
✔ Would you like to use the App Router (recommended)? · Yes
✔ Would you like to use the src/ directory? · Yes
✔ Test runner to use for end to end (E2E) tests · cypress
✔ Default stylesheet format · tailwind
✔ Which CI provider would you like to use? · circleci
✔ Will you be using GitHub as your git hosting provider? · No

A lots of questions here! This is why I am exploring Nx though.

alt text

After opening the project in Vscodium it is suggesting some packages to install.

I executed yarn and it is installing packages now.

The config I choose was very closely related to this documentation.

To run the project:

yarn nx run hello-nx-client:dev

I am missing Turborepo now.

alt text

Nice homepage.

To see the graph of project:

npx nx graph

alt text

Seems cool!

Adding new projects:

I want to add Nestjs backend: https://nx.dev/nx-api/nest

yarn nx add @nx/nest

Okay this command add nest dependancies to root package.json

To add a new app:

nx g @nx/nest:app apps/my-nest-app

Add nx as global package:

yarn global add nx 

alt text

See the graph

nx graph
Tags :