If I have a package-based monorepo with NX, which directory is projectRoot
, and which one is workspaceRoot
?
From the docs ( https://nx.dev/reference/project-configuration ):
{projectRoot} and {workspaceRoot}
{projectRoot} is a key word that is replaced by the path to the current project's root directory. {workspaceRoot} is a key word that is replaced by the path to the workspace root directory.
This is hilariously obvious and unhelpful explanation. I want to know which one is which, given I have this directory structure:
(git repo root dir)
|
+- nx.json
+- package.json - it says `"workspaces": [ "packages/*" ]`
|
+- packages/
|
+- package1/
+- package2/
Because package.json
mentions my packages/*
as "workspaces", my guess is that each package is a workspace, thus workspaceRoot
must refer to each package individually, while projectRoot
must refer to a top-level dir with my nx.json
config. But I have absolutely no idea how to confirm this. I'm experimenting with cache (setting various inputs
as seeing is it hits or misses), and absolutely nothing works.
To clarify what I'm confused about: Is "workspace root" a directory containing all the workspaces (ie packages), or does it mean "root directory of an individual workspace (ie package)." (Here I'm assuming that "workspace" == "package", which may not be true.)
Based on reading https://nx.dev/concepts/mental-model , here are my definitions:
packages/
packages/package1
and packages/package2
nx.json
is located In short:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.