You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 300/300/README.md
+106-1Lines changed: 106 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,11 +248,115 @@ If you were to use the absolute path `hatch-project/src/hatch_project`, it would
248
248
249
249
Adjust paths and options as necessary to fit your specific project structure. This configuration will help Nx Cloud identify and manage your workspace correctly.
250
250
251
-
Make sure to run the **build** command from the `/hatch-project/src` directory to ensure it recognizes the workspace correctly:
251
+
Make sure to run the **build** command from the `/hatch-project/src/hatch_project` directory - which contains the ```nx.json``` file - to ensure it recognizes the workspace correctly:
252
252
```
253
+
$ cd /hatch-project/src/hatch_project
253
254
$ nx build hatch_project
254
255
```
255
256
257
+
**Important**:
258
+
259
+
If you don't have `workspace.json` or `project.json`, and instead have `tsconfig.base.json`, you can adjust your setup as follows:
260
+
261
+
* Option: Single Application: **Create a `workspace.json`**: If your project is a single application, you can create a `workspace.json` file in the `hatch_project` directory. Here’s a basic example:
262
+
263
+
```json
264
+
{
265
+
"version": 1,
266
+
"projects": {
267
+
"hatch_project": {
268
+
"root": "src/hatch_project",
269
+
"sourceRoot": "src/hatch_project/src",
270
+
"projectType": "application"
271
+
}
272
+
}
273
+
}
274
+
```
275
+
276
+
* Option: Multiple Applications: If your Nx workspace contains multiple applications, you should structure your `workspace.json` (or `project.json`) to reflect each application. Here’s how to set it up:
277
+
278
+
### Example `workspace.json`
279
+
280
+
Create a `workspace.json` file in the `hatch_project` directory with the following structure:
281
+
282
+
```json
283
+
{
284
+
"version": 1,
285
+
"projects": {
286
+
"app1": {
287
+
"root": "src/hatch_project/app1",
288
+
"sourceRoot": "src/hatch_project/app1/src",
289
+
"projectType": "application"
290
+
},
291
+
"app2": {
292
+
"root": "src/hatch_project/app2",
293
+
"sourceRoot": "src/hatch_project/app2/src",
294
+
"projectType": "application"
295
+
},
296
+
"hatch_project": {
297
+
"root": "src/hatch_project",
298
+
"sourceRoot": "src/hatch_project/src",
299
+
"projectType": "application"
300
+
}
301
+
}
302
+
}
303
+
```
304
+
305
+
### Key Points:
306
+
-**Project Names**: Replace `app1`, `app2`, etc., with meaningful names for your applications.
307
+
-**Root and Source Root**: Adjust the `root` and `sourceRoot` paths to match the actual structure of your applications within the `hatch_project` directory.
308
+
309
+
### Additional Considerations:
310
+
-**Dependencies**: If applications depend on shared libraries or each other, ensure to define those dependencies in the `nx.json` file.
311
+
-**Configuration Files**: Each application may also have its own `tsconfig.json` if needed, or you can use a shared `tsconfig.base.json` for common settings.
312
+
313
+
### Example Directory Structure
314
+
Your directory structure might look like this:
315
+
316
+
```
317
+
/
318
+
└── hatch-project/
319
+
└── src/
320
+
└── hatch_project/
321
+
├── nx.json
322
+
├── workspace.json
323
+
├── tsconfig.base.json
324
+
├── app1/
325
+
│ └── src/
326
+
│ └── main.tsx
327
+
├── app2/
328
+
│ └── src/
329
+
│ └── main.tsx
330
+
```
331
+
332
+
### Running Commands
333
+
After setting up `workspace.json`, you can run commands like:
334
+
335
+
```bash
336
+
nx build app1
337
+
nx build app2
338
+
```
339
+
340
+
**Note**: `workspace.json` and `project.json` serve different purposes in an Nx workspace:
341
+
342
+
### `workspace.json`
343
+
-**Purpose**: It defines the overall structure of the Nx workspace.
344
+
-**Content**: Contains configurations for all projects within the workspace, including their paths, types, and any shared settings.
345
+
-**Usage**: Typically used in monorepos with multiple projects to manage and organize them centrally.
346
+
347
+
### `project.json`
348
+
-**Purpose**: It defines the configuration for an individual project within the workspace.
349
+
-**Content**: Contains specific settings, targets (like build, test, lint), and options for that particular project.
350
+
-**Usage**: Used when you want to modularize project configurations, allowing each project to have its own settings while still being part of the larger workspace.
351
+
352
+
### Summary
353
+
-**`workspace.json`**: Central configuration for the entire workspace.
354
+
-**`project.json`**: Specific configuration for individual projects.
355
+
356
+
In practice, you might use one or both depending on how you structure your Nx workspace. In newer versions of Nx, using `project.json` for individual projects is becoming more common.
357
+
358
+
This structure will help Nx Cloud recognize and manage multiple applications effectively.
359
+
256
360
This structure should allow Nx Cloud to detect the workspace properly.
257
361
258
362
Run the command to **connect** your workspace to Nx Cloud from the root directory of the nx monorepo `hatch project`, specifically:
@@ -285,3 +389,4 @@ For example to ignore any files in ```.next```:
0 commit comments