[英]NX package-based repo: projectRoot vs workspaceRoot?
If I have a package-based monorepo with NX, which directory is projectRoot
, and which one is workspaceRoot
?如果我有一个带有 NX 的基于包的 monorepo,哪个目录是
projectRoot
,哪个是workspaceRoot
?
From the docs ( https://nx.dev/reference/project-configuration ):从文档( https://nx.dev/reference/project-configuration ):
{projectRoot} and {workspaceRoot}
{projectRoot} 和 {workspaceRoot}
{projectRoot} is a key word that is replaced by the path to the current project's root directory.
{projectRoot} 是一个关键字,由当前项目根目录的路径替换。 {workspaceRoot} is a key word that is replaced by the path to the workspace root directory.
{workspaceRoot} 是一个关键字,由工作区根目录的路径替换。
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.因为
package.json
提到我的packages/*
作为“工作区”,我的猜测是每个 package 都是一个工作区,因此workspaceRoot
必须分别引用每个 package,而projectRoot
必须引用我的nx.json
配置的顶级目录。 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.我正在试验缓存(设置各种
inputs
,看它是命中还是未命中),但绝对没有任何效果。
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.)
(这里我假设“workspace”==“package”,这可能不是真的。)
Based on reading https://nx.dev/concepts/mental-model , here are my definitions:基于阅读https://nx.dev/concepts/mental-model ,这里是我的定义:
packages/
packages/
中的每个单独的子目录packages/package1
and packages/package2
packages/package1
和packages/package2
nx.json
is located nx.json
所在的根目录In short:简而言之:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.