docs(core): update caching and dte guides
This commit is contained in:
parent
de8871d103
commit
702350d48a
@ -327,7 +327,7 @@
|
||||
},
|
||||
"additionalProperties": true,
|
||||
"required": ["script"],
|
||||
"examplesFile": "`workspace.json`:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n\n```bash\nnx run frontend:build\n```\n\nThe `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory.\n\n#### Caching Artifacts\n\nBy default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"outputs\": [\"packages/frontend/dist\", \"packaged/frontend/docs\"],\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n",
|
||||
"examplesFile": "`workspace.json`:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n\n```bash\nnx run frontend:build\n```\n\nThe `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory.\n\n#### Caching Artifacts\n\nBy default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"outputs\": [\"{projectRoot}/dist\", \"{projectRoot}/docs\"],\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n",
|
||||
"presets": []
|
||||
},
|
||||
"description": "Run an NPM script using Nx.",
|
||||
|
||||
@ -776,7 +776,7 @@
|
||||
}
|
||||
},
|
||||
"required": ["platform", "entryFile", "bundleOutput"],
|
||||
"examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"outputs\": [\"apps/mobile/build\"],\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\"\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\"\n }\n }\n }\n}\n```\n\n```bash\nnx run mobile:bundle-ios\nnx run mobile:bundle-android\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Bundle with sourcemap\" %}\nThe `sourcemapOutput` option allows you to specify the path of the source map relative to app folder:\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"sourcemapOutput\": \"../../dist/apps/mobile/ios/main.map\",\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"sourcemapOutput\": \"../../dist/apps/mobile/android/main.map\",\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a dev/release bundle\" %}\n\nThe `dev` option determines whether to create a dev or release bundle. The default value is `true`, by setting it as `false`, warnings are disabled and the bundle is minified.\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"dev\": false\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"dev\": false\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a minified bundle\" %}\n\nThe `minify` option allows you to create a minified bundle:\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"minify\": true\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"minify\": true\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n",
|
||||
"examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"outputs\": [\"{projectRoot}/build\"],\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\"\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\"\n }\n }\n }\n}\n```\n\n```bash\nnx run mobile:bundle-ios\nnx run mobile:bundle-android\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Bundle with sourcemap\" %}\nThe `sourcemapOutput` option allows you to specify the path of the source map relative to app folder:\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"sourcemapOutput\": \"../../dist/apps/mobile/ios/main.map\",\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"sourcemapOutput\": \"../../dist/apps/mobile/android/main.map\",\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a dev/release bundle\" %}\n\nThe `dev` option determines whether to create a dev or release bundle. The default value is `true`, by setting it as `false`, warnings are disabled and the bundle is minified.\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"dev\": false\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"dev\": false\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a minified bundle\" %}\n\nThe `minify` option allows you to create a minified bundle:\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"minify\": true\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"minify\": true\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n",
|
||||
"presets": []
|
||||
},
|
||||
"description": "Builds the JavaScript bundle for offline use.",
|
||||
@ -811,7 +811,7 @@
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"apps/mobile/android/app/build/outputs/bundle\",\n \"apps/mobile/android/app/build/outputs/apk\"\n ],\n \"options\": {}\n }\n }\n}\n```\n\n```bash\nnx run mobile:build-android\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Build with custom gradleTask\" %}\nThe `gradleTask` option accepts any custom gradle task, such as `assembleDebug`, `assembleRelease`, `bundleDebug`, `bundleRelease`:\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"apps/mobile/android/app/build/outputs/bundle\",\n \"apps/mobile/android/app/build/outputs/apk\"\n ],\n \"options\": {\n \"gradleTask\": \"assembleDebug\"\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a build with apk format\" %}\n\nThe `apk` option allows you determine the format of android build. If set as true, it will create a build with `.apk` extension under apk folder; if set as false, it will create with `.aab` extension under bundle folder.\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"apps/mobile/android/app/build/outputs/bundle\",\n \"apps/mobile/android/app/build/outputs/apk\"\n ],\n \"options\": {\n \"apk\": true\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Build for debug/release\" %}\n\nIf set `debug` option as `true`, it will create a debug build; if set as `false`, it will create a release build.\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"apps/mobile/android/app/build/outputs/bundle\",\n \"apps/mobile/android/app/build/outputs/apk\"\n ],\n \"options\": {\n \"debug\": true\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n",
|
||||
"examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"{projectRoot}/build/outputs/bundle\",\n \"{projectRoot}/build/outputs/apk\"\n ],\n \"options\": {}\n }\n }\n}\n```\n\n```bash\nnx run mobile:build-android\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Build with custom gradleTask\" %}\nThe `gradleTask` option accepts any custom gradle task, such as `assembleDebug`, `assembleRelease`, `bundleDebug`, `bundleRelease`:\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"{projectRoot}/build/outputs/bundle\",\n \"{projectRoot}/build/outputs/apk\"\n ],\n \"options\": {\n \"gradleTask\": \"assembleDebug\"\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a build with apk format\" %}\n\nThe `apk` option allows you determine the format of android build. If set as true, it will create a build with `.apk` extension under apk folder; if set as false, it will create with `.aab` extension under bundle folder.\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"{projectRoot}/build/outputs/bundle\",\n \"{projectRoot}/build/outputs/apk\"\n ],\n \"options\": {\n \"apk\": true\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Build for debug/release\" %}\n\nIf set `debug` option as `true`, it will create a debug build; if set as `false`, it will create a release build.\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"{projectRoot}/build/outputs/bundle\",\n \"{projectRoot}/build/outputs/apk\"\n ],\n \"options\": {\n \"debug\": true\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n",
|
||||
"presets": []
|
||||
},
|
||||
"description": "Release Build for Android.",
|
||||
|
||||
@ -853,7 +853,7 @@
|
||||
},
|
||||
"additionalProperties": true,
|
||||
"required": ["script"],
|
||||
"examplesFile": "`workspace.json`:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n\n```bash\nnx run frontend:build\n```\n\nThe `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory.\n\n#### Caching Artifacts\n\nBy default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"outputs\": [\"packages/frontend/dist\", \"packaged/frontend/docs\"],\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n",
|
||||
"examplesFile": "`workspace.json`:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n\n```bash\nnx run frontend:build\n```\n\nThe `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory.\n\n#### Caching Artifacts\n\nBy default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"outputs\": [\"{projectRoot}/dist\", \"{projectRoot}/docs\"],\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n",
|
||||
"presets": []
|
||||
},
|
||||
"description": "Run an NPM script using Nx.",
|
||||
|
||||
@ -31,28 +31,41 @@ the result of the test run.
|
||||
|
||||
Now, run the following command twice. The second time the operation will be instant:
|
||||
|
||||
```{% command="nx test header"%}
|
||||
> nx run header:test [existing outputs match the cache, left as is]
|
||||
```shell
|
||||
nx build header
|
||||
```
|
||||
|
||||
> header@0.0.0 test
|
||||
> jest
|
||||
```{% command="nx build header"%}
|
||||
> nx run header:build [local cache]
|
||||
|
||||
PASS src/Header.spec.tsx
|
||||
✓ renders header (14 ms)
|
||||
|
||||
Test Suites: 1 passed, 1 total
|
||||
Tests: 1 passed, 1 total
|
||||
Snapshots: 0 total
|
||||
Time: 0.528 s, estimated 2 s
|
||||
Ran all test suites.
|
||||
> header@0.0.0 build
|
||||
> rimraf dist && rollup --config
|
||||
|
||||
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target test for project header (4ms)
|
||||
src/index.tsx → dist...
|
||||
created dist in 858ms
|
||||
|
||||
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project header (13ms)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
|
||||
```
|
||||
|
||||
## Replaying from Cache
|
||||
|
||||
When Nx determines that the inputs for a task have not changed, it recreates the outputs of that task as if it actually ran on your machine - but much faster. The outputs of a cached task include both the terminal output and the files created in the defined `output` directories for that task.
|
||||
|
||||
You can test this out by deleting the `dist` folder that the `header:build` task outputs to and then running `nx build header` again. The cached task will replay instantly and the correct files will be present in the `dist` folder.
|
||||
|
||||
```treeview
|
||||
header/
|
||||
└── dist/ <-- this folder gets recreated
|
||||
```
|
||||
|
||||
If your task creates output artifacts in a different location, you can [change the output folder(s)](/reference/project-configuration#outputs) that are cached. You can also [customize which inputs](/more-concepts/customizing-inputs) will invalidate the cache if they are changed.
|
||||
|
||||
## Advanced Caching
|
||||
|
||||
For a more in-depth understanding of the caching implementation and to fine-tune the caching for your repo, read [How Caching Works](/concepts/how-caching-works).
|
||||
@ -75,6 +88,76 @@ You can connect your workspace to Nx Cloud by running:
|
||||
npx nx connect-to-nx-cloud
|
||||
```
|
||||
|
||||
```{% command="npx nx connect-to-nx-cloud"%}
|
||||
✔ Enable distributed caching to make your CI faster · Yes
|
||||
|
||||
> NX Generating @nrwl/nx-cloud:init
|
||||
|
||||
UPDATE nx.json
|
||||
|
||||
> NX Distributed caching via Nx Cloud has been enabled
|
||||
|
||||
In addition to the caching, Nx Cloud provides config-free distributed execution,
|
||||
UI for viewing complex runs and GitHub integration. Learn more at https://nx.app
|
||||
|
||||
Your workspace is currently unclaimed. Run details from unclaimed workspaces can be viewed on cloud.nx.app by anyone
|
||||
with the link. Claim your workspace at the following link to restrict access.
|
||||
|
||||
https://cloud.nx.app/orgs/workspace-setup?accessToken=YOURACCESSTOKEN
|
||||
```
|
||||
|
||||
To see the remote cache in action, run:
|
||||
|
||||
```shell
|
||||
nx build header && nx reset && nx build header
|
||||
```
|
||||
|
||||
```{% command="nx build header && nx reset && nx build header"%}
|
||||
> nx run header:build
|
||||
|
||||
> header@0.0.0 build
|
||||
> rimraf dist && rollup --config
|
||||
|
||||
src/index.tsx → dist...
|
||||
created dist in 786ms
|
||||
|
||||
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project header (2s)
|
||||
|
||||
See logs and investigate cache misses at https://cloud.nx.app/runs/k0HDHACpL8
|
||||
|
||||
|
||||
> NX Resetting the Nx workspace cache and stopping the Nx Daemon.
|
||||
|
||||
This might take a few minutes.
|
||||
|
||||
|
||||
> NX Daemon Server - Stopped
|
||||
|
||||
|
||||
> NX Successfully reset the Nx workspace.
|
||||
|
||||
|
||||
> nx run header:build [remote cache]
|
||||
|
||||
|
||||
> header@0.0.0 build
|
||||
> rimraf dist && rollup --config
|
||||
|
||||
|
||||
src/index.tsx → dist...
|
||||
created dist in 786ms
|
||||
|
||||
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project header (664ms)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
|
||||
|
||||
Nx Cloud made it possible to reuse header: https://nx.app/runs/P0X6ZGTkqZ
|
||||
```
|
||||
|
||||
## See Also:
|
||||
|
||||
- [Nx Cloud Documentation](/nx-cloud/intro/what-is-nx-cloud)
|
||||
|
||||
@ -1,8 +1,18 @@
|
||||
# Distribute Task Execution (DTE)
|
||||
|
||||
Nx supports running commands across multiple machines. You can either set it up by hand (by using batching or binning) or use Nx Cloud.
|
||||
Nx speeds up your average CI time with [caching](/core-features/cache-task-results) and the [affected command](/concepts/affected). But neither of these features help with the worst case scenario. When something at the core of your repo has been modified and every task needs to be run in CI, the only way to improve the performance is by adding more agent jobs and efficiently parallelizing the tasks.
|
||||
|
||||
[Read the comparison of the two approaches.](https://blog.nrwl.io/distributing-ci-binning-and-distributed-task-execution-632fe31a8953?source=friends_link&sk=5120b7ff982730854ed22becfe7a640a)
|
||||
The most obvious way to parallelize tasks is to split tasks up by type: running all tests on one job, all builds on another and all lint tasks on a third. This strategy is called binning. This can be made difficult if some test tasks have build tasks as prerequisites, but assuming you figure out some way to handle that, a typical set up can look like the diagram below. Here the test tasks are delayed until all necessary build artifacts are ready, but the build and lint tasks can start right away.
|
||||
|
||||

|
||||
|
||||
The problem with the binning approach is you'll end up with some idle time on one or more jobs. Nx's distributed task execution reduces that idle time to the minimum possible by assigning each individual task to agent jobs based on the task's average run time. Nx also guarantees that tasks are executed in the correct order and uses distributed caching to make sure that build artifacts from previous tasks are present on every agent job that needs them.
|
||||
|
||||
When you set up Nx's distributed task execution, your task graph will look more like this:
|
||||
|
||||

|
||||
|
||||
And not only will CI finish faster, but the debugging experience is the same as if you ran all of your CI on a single job. That's because Nx uses distributed caching to recreate all of the logs and build artifacts on the main job.
|
||||
|
||||
## Set up
|
||||
|
||||
@ -20,10 +30,10 @@ The `--ci` flag can be `github`, `circleci` or `azure`. For more details on sett
|
||||
|
||||
## CI Execution Flow
|
||||
|
||||
There are two main parts to the CI set up:
|
||||
Distributed task execution can work on any CI provider. You are responsible for launching jobs in your CI system. Nx Cloud then coordinates the way those jobs work together. There are two different kinds of jobs that you'll need to create in your CI system.
|
||||
|
||||
1. The main job that controls what is going to be executed
|
||||
2. The agent jobs that actually execute the tasks
|
||||
1. One main job that controls what is going to be executed
|
||||
2. Multiple agent jobs that actually execute the tasks
|
||||
|
||||
The main job execution flow looks like this:
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ the name of the target.
|
||||
|
||||
## Run Tasks Affected by a PR
|
||||
|
||||
You can also run a command for all the projects affected in your PR like this:
|
||||
You can also run a command for all the projects affected by your PR like this:
|
||||
|
||||
```shell
|
||||
npx nx affected --target=test
|
||||
|
||||
@ -50,7 +50,7 @@ builds scenario:
|
||||
"build": {
|
||||
"executor": "@nrwl/angular:ng-packagr-lite",
|
||||
"outputs": [
|
||||
"dist/libs/my-lib"
|
||||
"{workspaceRoot}/dist/libs/my-lib"
|
||||
],
|
||||
"options": {
|
||||
...
|
||||
@ -255,7 +255,7 @@ depends on must also be `build-base`:
|
||||
"build-base": {
|
||||
"executor": "@nrwl/angular:ng-packagr-lite",
|
||||
"outputs": [
|
||||
"dist/libs/my-lib"
|
||||
"{workspaceRoot}/dist/libs/my-lib"
|
||||
],
|
||||
"options": {
|
||||
...
|
||||
|
||||
@ -444,7 +444,7 @@ Next, you need to configure your project to build the theme when you build the l
|
||||
...
|
||||
"build-angular": {
|
||||
"executor": "@nrwl/angular:package",
|
||||
"outputs": ["dist/libs/lib1"],
|
||||
"outputs": ["{workspaceRoot}/dist/libs/lib1"],
|
||||
"options": {
|
||||
"project": "libs/lib1/ng-package.json",
|
||||
"tailwindConfig": "libs/lib1/tailwind.config.js"
|
||||
@ -461,7 +461,7 @@ Next, you need to configure your project to build the theme when you build the l
|
||||
},
|
||||
"build-lib": {
|
||||
"executor": "nx:run-commands",
|
||||
"outputs": ["dist/libs/lib1"],
|
||||
"outputs": ["{workspaceRoot}/dist/libs/lib1"],
|
||||
"configurations": {
|
||||
"production": {
|
||||
"commands": [
|
||||
@ -480,7 +480,7 @@ Next, you need to configure your project to build the theme when you build the l
|
||||
},
|
||||
"build": {
|
||||
"executor": "nx:run-commands",
|
||||
"outputs": ["dist/libs/lib1"],
|
||||
"outputs": ["{workspaceRoot}/dist/libs/lib1"],
|
||||
"configurations": {
|
||||
"production": {
|
||||
"commands": [
|
||||
|
||||
66
docs/shared/images/dte/3agents.svg
Normal file
66
docs/shared/images/dte/3agents.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 66 KiB |
29
docs/shared/images/dte/binning.svg
Normal file
29
docs/shared/images/dte/binning.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 90 KiB |
@ -60,7 +60,7 @@ Let’s look at the test target relying on its dependencies.
|
||||
{
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["coverage/apps/app1"],
|
||||
"outputs": ["{workspaceRoot}/coverage/apps/app1"],
|
||||
"dependsOn": ["^test"],
|
||||
"options": {
|
||||
"jestConfig": "apps/app1/jest.config.js",
|
||||
|
||||
@ -39,7 +39,7 @@ Here's the `project.json` file for your `products-data-client` project:
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["coverage/libs/products-data-client"],
|
||||
"outputs": ["{workspaceRoot}/coverage/libs/products-data-client"],
|
||||
"options": {
|
||||
"jestConfig": "libs/products-data-client/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
|
||||
@ -128,7 +128,7 @@ Outputs are defined for every target in your workspace:
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["coverage/libs/products-data-client"],
|
||||
"outputs": ["{workspaceRoot}/coverage/libs/products-data-client"],
|
||||
"options": {
|
||||
"jestConfig": "libs/products-data-client/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
|
||||
@ -31,7 +31,7 @@ Here's the `project.json` file for your `common-ui` project:
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["coverage/libs/common-ui"],
|
||||
"outputs": ["{workspaceRoot}/coverage/libs/common-ui"],
|
||||
"options": {
|
||||
"jestConfig": "libs/common-ui/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
|
||||
@ -84,7 +84,7 @@ Outputs are defined for every target in your workspace:
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["coverage/libs/products"],
|
||||
"outputs": ["{workspaceRoot}/coverage/libs/products"],
|
||||
"options": {
|
||||
"jestConfig": "libs/products/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
|
||||
@ -6,7 +6,7 @@ The `configurations` property provides extra sets of values that will be merged
|
||||
{
|
||||
"build": {
|
||||
"executor": "@nrwl/js:tsc",
|
||||
"outputs": ["dist/libs/mylib"],
|
||||
"outputs": ["{workspaceRoot}/dist/libs/mylib"],
|
||||
"dependsOn": ["^build"],
|
||||
"options": {
|
||||
"tsConfig": "libs/mylib/tsconfig.lib.json",
|
||||
|
||||
@ -175,7 +175,7 @@ Another target default you can configure is `outputs`:
|
||||
{
|
||||
"targetDefaults": {
|
||||
"build": {
|
||||
"outputs": ["./custom-dist"]
|
||||
"outputs": ["{projectRoot}/custom-dist"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,22 +56,18 @@ You can add Nx-specific configuration as follows:
|
||||
{
|
||||
"name": "mylib",
|
||||
"scripts": {
|
||||
"test: "jest",
|
||||
"test": "jest",
|
||||
"build": "tsc -p tsconfig.lib.json" // the actual command here is arbitrary
|
||||
},
|
||||
"nx": {
|
||||
"namedInputs": {
|
||||
"default": [
|
||||
"{projectRoot}/**/*"
|
||||
],
|
||||
"production": [
|
||||
"!{projectRoot}/**/*.spec.tsx"
|
||||
]
|
||||
"default": ["{projectRoot}/**/*"],
|
||||
"production": ["!{projectRoot}/**/*.spec.tsx"]
|
||||
},
|
||||
"targets": {
|
||||
"build": {
|
||||
"inputs": ["production", "^production"],
|
||||
"outputs": ["dist/libs/mylib"],
|
||||
"outputs": ["{workspaceRoot}/dist/libs/mylib"],
|
||||
"dependsOn": ["^build"]
|
||||
},
|
||||
"test": {
|
||||
@ -107,7 +103,7 @@ You can add Nx-specific configuration as follows:
|
||||
"build": {
|
||||
"executor": "@nrwl/js:tsc",
|
||||
"inputs": ["production", "^production"],
|
||||
"outputs": ["dist/libs/mylib"],
|
||||
"outputs": ["{workspaceRoot}/dist/libs/mylib"],
|
||||
"dependsOn": ["^build"],
|
||||
"options": {}
|
||||
}
|
||||
@ -192,7 +188,7 @@ sources (non-test sources) of its dependencies. In other words, it treats test s
|
||||
|
||||
### outputs
|
||||
|
||||
Targets may define outputs to tell Nx where the target is going to create file artifacts that Nx should cache. `"outputs": ["dist/libs/mylib"]` tells Nx where the `build` target is going to create file artifacts.
|
||||
Targets may define outputs to tell Nx where the target is going to create file artifacts that Nx should cache. `"outputs": ["{workspaceRoot}/dist/libs/mylib"]` tells Nx where the `build` target is going to create file artifacts.
|
||||
|
||||
This configuration is usually not needed. Nx comes with reasonable defaults (imported in `nx.json`) which implement the configuration above.
|
||||
|
||||
@ -203,7 +199,10 @@ Usually, a target writes to a specific directory or a file. The following instru
|
||||
```json
|
||||
{
|
||||
"build": {
|
||||
"outputs": ["dist/libs/mylib", "build/libs/mylib/main.js"]
|
||||
"outputs": [
|
||||
"{workspaceRoot}/dist/libs/mylib",
|
||||
"{workspaceRoot}/build/libs/mylib/main.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -215,10 +214,10 @@ Sometimes, multiple targets might write to the same directory. When possible it
|
||||
```json
|
||||
{
|
||||
"build-js": {
|
||||
"outputs": ["dist/libs/mylib/js"]
|
||||
"outputs": ["{workspaceRoot}/dist/libs/mylib/js"]
|
||||
},
|
||||
"build-css": {
|
||||
"outputs": ["dist/libs/mylib/css"]
|
||||
"outputs": ["{workspaceRoot}/dist/libs/mylib/css"]
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -228,10 +227,10 @@ But if the above is not possible, globs can be specified as outputs to only cach
|
||||
```json
|
||||
{
|
||||
"build-js": {
|
||||
"outputs": ["dist/libs/mylib/**/*.js"]
|
||||
"outputs": ["{workspaceRoot}/dist/libs/mylib/**/*.js"]
|
||||
},
|
||||
"build-css": {
|
||||
"outputs": ["dist/libs/mylib/**/*.css"]
|
||||
"outputs": ["{workspaceRoot}/dist/libs/mylib/**/*.css"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -30,7 +30,7 @@ By default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/di
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "nx:run-script",
|
||||
"outputs": ["packages/frontend/dist", "packaged/frontend/docs"],
|
||||
"outputs": ["{projectRoot}/dist", "{projectRoot}/docs"],
|
||||
"options": {
|
||||
"script": "build-my-project"
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
"build-android": {
|
||||
"executor": "@nrwl/react-native:build-android",
|
||||
"outputs": [
|
||||
"apps/mobile/android/app/build/outputs/bundle",
|
||||
"apps/mobile/android/app/build/outputs/apk"
|
||||
"{projectRoot}/build/outputs/bundle",
|
||||
"{projectRoot}/build/outputs/apk"
|
||||
],
|
||||
"options": {}
|
||||
}
|
||||
@ -32,8 +32,8 @@ The `gradleTask` option accepts any custom gradle task, such as `assembleDebug`,
|
||||
"build-android": {
|
||||
"executor": "@nrwl/react-native:build-android",
|
||||
"outputs": [
|
||||
"apps/mobile/android/app/build/outputs/bundle",
|
||||
"apps/mobile/android/app/build/outputs/apk"
|
||||
"{projectRoot}/build/outputs/bundle",
|
||||
"{projectRoot}/build/outputs/apk"
|
||||
],
|
||||
"options": {
|
||||
"gradleTask": "assembleDebug"
|
||||
@ -50,8 +50,8 @@ The `apk` option allows you determine the format of android build. If set as tru
|
||||
"build-android": {
|
||||
"executor": "@nrwl/react-native:build-android",
|
||||
"outputs": [
|
||||
"apps/mobile/android/app/build/outputs/bundle",
|
||||
"apps/mobile/android/app/build/outputs/apk"
|
||||
"{projectRoot}/build/outputs/bundle",
|
||||
"{projectRoot}/build/outputs/apk"
|
||||
],
|
||||
"options": {
|
||||
"apk": true
|
||||
@ -68,8 +68,8 @@ If set `debug` option as `true`, it will create a debug build; if set as `false`
|
||||
"build-android": {
|
||||
"executor": "@nrwl/react-native:build-android",
|
||||
"outputs": [
|
||||
"apps/mobile/android/app/build/outputs/bundle",
|
||||
"apps/mobile/android/app/build/outputs/apk"
|
||||
"{projectRoot}/build/outputs/bundle",
|
||||
"{projectRoot}/build/outputs/apk"
|
||||
],
|
||||
"options": {
|
||||
"debug": true
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
//...
|
||||
"bundle-ios": {
|
||||
"executor": "@nrwl/react-native:bundle",
|
||||
"outputs": ["apps/mobile/build"],
|
||||
"outputs": ["{projectRoot}/build"],
|
||||
"options": {
|
||||
"entryFile": "src/main.tsx",
|
||||
"platform": "ios",
|
||||
|
||||
@ -30,7 +30,7 @@ By default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/di
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "nx:run-script",
|
||||
"outputs": ["packages/frontend/dist", "packaged/frontend/docs"],
|
||||
"outputs": ["{projectRoot}/dist", "{projectRoot}/docs"],
|
||||
"options": {
|
||||
"script": "build-my-project"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user