Background:

I've been following multiple nx videos and installation guides which claim to be simple with npx add-nx-to-monorepo. The guides then talk about editing workspace.json, which is deprecated, and that the packages.json files in (what I assume is) the current working directory and those recursively stored in child directories of the working directory will be detected.. but I'm missing something because I see nothing of the sort, nor really a guide to configuring nx.json or edit the autogenerated config files to make them do anything. And this Project Configuration page has me more confused than guided on how to configure the thing.

My scenario:

I'm trying to improve build times, introduce caching and local testing to a github repository. The projects exist already and are in production. I've merged 16 github repositories into a single monorepo for testing, but i'll summarise it with just 3.

My directory structure:

monorepo
`- apps
  `- adminportal
    `- frontend - .NET
    `- backend  - NextJS
  `- clientportal
    `- frontend - .NET 
    `- backend  - NextJS
`- libs
  `- common-library

Going into monorepo/apps/adminportal/backend, typing nx init configures the directory correctly, I can nx build my project and it caches correctly, the second build taking miliseconds instead of 1-2 minutes. The same with clientportal/backend.

Where I'm confused is, I'm supposed to be able to do this from the root monorepo/ directory, and be able to build all backends, or all projects if they have changed.

I've tried to configure the root directory with npx create-nx-workspace but I'm told by the nx Discord that this is only for fresh projects.

I've tried npx add-nx-to-monorepo but this just gives me an nx.json, nx, nx.bat and a .gitignore. There's no workspaces.conf (deprecated as I mentioned above), no package.json.. what am I supposed to do here to make the root directory nx work with the subdirectories?

Is there actually some way of using nx init in a subdirectory then joining this to the workspace in its own parent directory (monorepo/ in my case)?

Appreciate any guidance or links to actual up to date documentation or guides.

0

There are 0 best solutions below