Compare commits
138 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 585d702614 | |||
| a9d39c4c8f | |||
| 666c1f470b | |||
| 5264cf6c29 | |||
| d54e934303 | |||
| 1d8f3baef8 | |||
| 1f6baa753f | |||
| 2dac233cf8 | |||
| 9aedc68923 | |||
| 7cc1a999d4 | |||
| 81a347d568 | |||
| e0077ca2ea | |||
| 93cbdb4b14 | |||
| b0f4a17621 | |||
| 6e50dfcd0f | |||
| b1fa2bd0cf | |||
| e8209ec847 | |||
| b724efe7f3 | |||
| 3194ed3347 | |||
| de9b6d271d | |||
| c4cacf1fb2 | |||
| 2cf9d1e6cd | |||
| fe1ac80f8c | |||
| 662b7089ed | |||
| 3cde493b99 | |||
| e9748326ff | |||
| da46c303e8 | |||
| 39a449ff08 | |||
| 40233a2949 | |||
| 85c840d92f | |||
| c7731e0044 | |||
| 97b0282c7b | |||
| 4acc245b50 | |||
| abe273df5a | |||
| b7f0bdffa4 | |||
| d55add9b46 | |||
| a1e22c08d5 | |||
| 71ae788eae | |||
| afc9c988be | |||
| a36d5c61b0 | |||
| 0ecfcc4e61 | |||
| e9af4b309e | |||
| b9d4a53913 | |||
| 5e21d4cfc2 | |||
| ca14bb0490 | |||
| 462dee750f | |||
| 3054cad0c4 | |||
| 97eea7c10a | |||
| 813b3dbb74 | |||
| 0a3d4616e3 | |||
| c9407dda14 | |||
| 4bbf4f1efe | |||
| 58435682f1 | |||
| a0f2d4be0f | |||
| 705ca029b4 | |||
| e46d9def17 | |||
| 714e140f6a | |||
| ebdbc455a3 | |||
| 25fe0d260a | |||
| 5e7a074ed3 | |||
| 7e64aae099 | |||
| 02ff0bd0b2 | |||
| e4c40d66e0 | |||
| a50d119d73 | |||
| c5f2e80a0e | |||
| 78ef14e8c5 | |||
| 73a013cd8c | |||
| 4adc24fab4 | |||
| 342ce28673 | |||
| 1c161c61d5 | |||
| d7f5cb0a12 | |||
| c5cc33b762 | |||
| ebbd798b4e | |||
| b2acd0fcef | |||
| ad43e66deb | |||
| efdda7b22f | |||
| 076e7fce2a | |||
| d427edbcc1 | |||
| f7597465ea | |||
| ae090ef35c | |||
| 5b507042d5 | |||
| dc48960240 | |||
| db78715a70 | |||
| 3ecf9a0ae4 | |||
| 90a10a89c4 | |||
| 36235051fb | |||
| 8464b64ea7 | |||
| 280056c7a0 | |||
| d7815fa2a5 | |||
| 89797d2f7a | |||
| b0506c9f8f | |||
| 5b3af217ed | |||
| 49b3bdda30 | |||
| d64deae065 | |||
| 785178969e | |||
| 3eb2090c09 | |||
| 68ebcca812 | |||
| 5683b5389e | |||
| f49fa31b7c | |||
| 3078ecf66f | |||
| 37649ebfd4 | |||
| 9bf2613f9e | |||
| e8d2b471a8 | |||
| acdf13b67a | |||
| 5315052fc4 | |||
| 3b4ac84a30 | |||
| 985fb4c9d3 | |||
| 88859bf37e | |||
| 67d47a6c49 | |||
| ee06f0fd83 | |||
| c638f6b0b9 | |||
| 3d2ffc9d3f | |||
| 7b0c86924f | |||
| fde900b607 | |||
| 2ebfee5781 | |||
| 7ee4137638 | |||
| 5a8a56dc15 | |||
| f7ed73d088 | |||
| cb8e02bf88 | |||
| fbb24615b2 | |||
| df446f7b1e | |||
| 2a7743c543 | |||
| 563ebc2494 | |||
| 31f61f8527 | |||
| 8764424e9b | |||
| 81d73e3512 | |||
| 4056645034 | |||
| 66f3bcb633 | |||
| bbe8e6678d | |||
| c5a44ef4ae | |||
| 8dd1db291e | |||
| 1fe809f6d6 | |||
| 489aa8f2e0 | |||
| 7a44f6ea22 | |||
| 577061c5a1 | |||
| 984edacd41 | |||
| 7163769b39 | |||
| 01831e3e67 |
@@ -6,7 +6,7 @@ version: 2.1
|
||||
orbs:
|
||||
nx: nrwl/nx@1.6.2
|
||||
rust: circleci/rust@1.6.0
|
||||
browser-tools: circleci/browser-tools@1.4.6
|
||||
browser-tools: circleci/browser-tools@1.4.8
|
||||
|
||||
# -------------------------
|
||||
# EXECUTORS
|
||||
|
||||
@@ -31,6 +31,7 @@ CHANGELOG.md
|
||||
|
||||
# Next.js
|
||||
.next
|
||||
out
|
||||
|
||||
# Angular Cache
|
||||
.angular
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
launch-templates:
|
||||
linux-medium:
|
||||
resource-class: 'docker_linux_amd64/medium+'
|
||||
image: 'ubuntu22.04-node20.9-v2'
|
||||
image: 'ubuntu22.04-node20.9-v3'
|
||||
env:
|
||||
GIT_AUTHOR_EMAIL: test@test.com
|
||||
GIT_AUTHOR_NAME: Test
|
||||
@@ -21,7 +21,10 @@ launch-templates:
|
||||
~/.cache/Cypress
|
||||
~/.pnpm-store
|
||||
BASE_BRANCH: 'master'
|
||||
|
||||
- name: Install e2e deps
|
||||
script: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ca-certificates lsof
|
||||
- name: Install Pnpm
|
||||
script: |
|
||||
npm install -g @pnpm/exe@8.7.4
|
||||
|
||||
Generated
+4
-5
@@ -482,9 +482,8 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||
|
||||
[[package]]
|
||||
name = "filedescriptor"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7199d965852c3bac31f779ef99cbb4537f80e952e2d6aa0ffeb30cce00f4f46e"
|
||||
version = "0.8.3"
|
||||
source = "git+https://github.com/cammisuli/wezterm#3db3f2d05f7188af9c7527214605f18332fac06d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"thiserror",
|
||||
@@ -1537,6 +1536,7 @@ dependencies = [
|
||||
"ignore",
|
||||
"ignore-files 2.0.0",
|
||||
"itertools",
|
||||
"mio",
|
||||
"napi",
|
||||
"napi-build",
|
||||
"napi-derive",
|
||||
@@ -1660,8 +1660,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "portable-pty"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "806ee80c2a03dbe1a9fb9534f8d19e4c0546b790cde8fd1fea9d6390644cb0be"
|
||||
source = "git+https://github.com/cammisuli/wezterm#3db3f2d05f7188af9c7527214605f18332fac06d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 1.3.2",
|
||||
|
||||
@@ -454,9 +454,19 @@
|
||||
"description": "Nx plugin to support Firebase Apps and Cloud Functions in Nx workspaces",
|
||||
"url": "https://github.com/simondotm/nx-firebase"
|
||||
},
|
||||
{
|
||||
"name": "@dman926/nx-python-pdm",
|
||||
"description": "Use Python in NX workspaces with PDM",
|
||||
"url": "https://github.com/dman926/nx-python-pdm"
|
||||
},
|
||||
{
|
||||
"name": "@gnuechtel/nx-cucumber",
|
||||
"description": "Plugin to use Cucumber within Nx workspaces",
|
||||
"url": "https://gitlab.com/gnuechtel/open-source/-/tree/main/libs/nx-cucumber"
|
||||
},
|
||||
{
|
||||
"name": "@analogjs/platform",
|
||||
"description": "Official plugin to add Analog to your Nx monorepo.",
|
||||
"url": "https://analogjs.org/docs/integrations/nx"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -9,7 +9,7 @@ Description of a file change in the Nx virtual file system/
|
||||
- [content](../../devkit/documents/FileChange#content): Buffer
|
||||
- [options](../../devkit/documents/FileChange#options): TreeWriteOptions
|
||||
- [path](../../devkit/documents/FileChange#path): string
|
||||
- [type](../../devkit/documents/FileChange#type): "DELETE" | "CREATE" | "UPDATE"
|
||||
- [type](../../devkit/documents/FileChange#type): "CREATE" | "DELETE" | "UPDATE"
|
||||
|
||||
## Properties
|
||||
|
||||
@@ -39,6 +39,6 @@ Path relative to the workspace root
|
||||
|
||||
### type
|
||||
|
||||
• **type**: `"DELETE"` \| `"CREATE"` \| `"UPDATE"`
|
||||
• **type**: `"CREATE"` \| `"DELETE"` \| `"UPDATE"`
|
||||
|
||||
Type of change: 'CREATE' | 'DELETE' | 'UPDATE'
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
},
|
||||
{
|
||||
"id": "split-e2e-tasks",
|
||||
"name": "Automatically Split E2E Tasks",
|
||||
"name": "Automatically Split E2E Tasks (TestAtomizer)",
|
||||
"description": "",
|
||||
"mediaImage": "",
|
||||
"file": "nx-cloud/features/split-e2e-tasks",
|
||||
@@ -258,7 +258,7 @@
|
||||
},
|
||||
"/ci/features/split-e2e-tasks": {
|
||||
"id": "split-e2e-tasks",
|
||||
"name": "Automatically Split E2E Tasks",
|
||||
"name": "Automatically Split E2E Tasks (TestAtomizer)",
|
||||
"description": "",
|
||||
"mediaImage": "",
|
||||
"file": "nx-cloud/features/split-e2e-tasks",
|
||||
@@ -675,6 +675,29 @@
|
||||
"path": "/ci/recipes/on-premise",
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
"id": "troubleshooting",
|
||||
"name": "Troubleshooting",
|
||||
"description": "Learn how to solve common issues in Nx Cloud.",
|
||||
"mediaImage": "",
|
||||
"file": "",
|
||||
"itemList": [
|
||||
{
|
||||
"id": "ci-execution-failed",
|
||||
"name": "CI Execution Failed",
|
||||
"description": "",
|
||||
"mediaImage": "",
|
||||
"file": "nx-cloud/troubleshooting/ci-execution-failed",
|
||||
"itemList": [],
|
||||
"isExternal": false,
|
||||
"path": "/ci/recipes/troubleshooting/ci-execution-failed",
|
||||
"tags": []
|
||||
}
|
||||
],
|
||||
"isExternal": false,
|
||||
"path": "/ci/recipes/troubleshooting",
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
"id": "other",
|
||||
"name": "Other",
|
||||
@@ -1224,6 +1247,40 @@
|
||||
"path": "/ci/recipes/on-premise/advanced-config",
|
||||
"tags": []
|
||||
},
|
||||
"/ci/recipes/troubleshooting": {
|
||||
"id": "troubleshooting",
|
||||
"name": "Troubleshooting",
|
||||
"description": "Learn how to solve common issues in Nx Cloud.",
|
||||
"mediaImage": "",
|
||||
"file": "",
|
||||
"itemList": [
|
||||
{
|
||||
"id": "ci-execution-failed",
|
||||
"name": "CI Execution Failed",
|
||||
"description": "",
|
||||
"mediaImage": "",
|
||||
"file": "nx-cloud/troubleshooting/ci-execution-failed",
|
||||
"itemList": [],
|
||||
"isExternal": false,
|
||||
"path": "/ci/recipes/troubleshooting/ci-execution-failed",
|
||||
"tags": []
|
||||
}
|
||||
],
|
||||
"isExternal": false,
|
||||
"path": "/ci/recipes/troubleshooting",
|
||||
"tags": []
|
||||
},
|
||||
"/ci/recipes/troubleshooting/ci-execution-failed": {
|
||||
"id": "ci-execution-failed",
|
||||
"name": "CI Execution Failed",
|
||||
"description": "",
|
||||
"mediaImage": "",
|
||||
"file": "nx-cloud/troubleshooting/ci-execution-failed",
|
||||
"itemList": [],
|
||||
"isExternal": false,
|
||||
"path": "/ci/recipes/troubleshooting/ci-execution-failed",
|
||||
"tags": []
|
||||
},
|
||||
"/ci/recipes/other": {
|
||||
"id": "other",
|
||||
"name": "Other",
|
||||
|
||||
@@ -5005,9 +5005,9 @@
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Angular: The browserTarget",
|
||||
"path": "/deprecated/storybook/angular-browser-target",
|
||||
"id": "angular-browser-target",
|
||||
"name": "Angular - The projectBuildConfig",
|
||||
"path": "/deprecated/storybook/angular-project-build-config",
|
||||
"id": "angular-project-build-config",
|
||||
"isExternal": false,
|
||||
"children": [],
|
||||
"disableCollapsible": false
|
||||
@@ -5161,9 +5161,9 @@
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Angular: The browserTarget",
|
||||
"path": "/deprecated/storybook/angular-browser-target",
|
||||
"id": "angular-browser-target",
|
||||
"name": "Angular - The projectBuildConfig",
|
||||
"path": "/deprecated/storybook/angular-project-build-config",
|
||||
"id": "angular-project-build-config",
|
||||
"isExternal": false,
|
||||
"children": [],
|
||||
"disableCollapsible": false
|
||||
@@ -5212,9 +5212,9 @@
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Angular: The browserTarget",
|
||||
"path": "/deprecated/storybook/angular-browser-target",
|
||||
"id": "angular-browser-target",
|
||||
"name": "Angular - The projectBuildConfig",
|
||||
"path": "/deprecated/storybook/angular-project-build-config",
|
||||
"id": "angular-project-build-config",
|
||||
"isExternal": false,
|
||||
"children": [],
|
||||
"disableCollapsible": false
|
||||
@@ -5779,7 +5779,7 @@
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Automatically Split E2E Tasks",
|
||||
"name": "Automatically Split E2E Tasks (TestAtomizer)",
|
||||
"path": "/ci/features/split-e2e-tasks",
|
||||
"id": "split-e2e-tasks",
|
||||
"isExternal": false,
|
||||
@@ -5838,7 +5838,7 @@
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Automatically Split E2E Tasks",
|
||||
"name": "Automatically Split E2E Tasks (TestAtomizer)",
|
||||
"path": "/ci/features/split-e2e-tasks",
|
||||
"id": "split-e2e-tasks",
|
||||
"isExternal": false,
|
||||
@@ -6144,6 +6144,23 @@
|
||||
],
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Troubleshooting",
|
||||
"path": "/ci/recipes/troubleshooting",
|
||||
"id": "troubleshooting",
|
||||
"isExternal": false,
|
||||
"children": [
|
||||
{
|
||||
"name": "CI Execution Failed",
|
||||
"path": "/ci/recipes/troubleshooting/ci-execution-failed",
|
||||
"id": "ci-execution-failed",
|
||||
"isExternal": false,
|
||||
"children": [],
|
||||
"disableCollapsible": false
|
||||
}
|
||||
],
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Other",
|
||||
"path": "/ci/recipes/other",
|
||||
@@ -6544,6 +6561,31 @@
|
||||
"children": [],
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Troubleshooting",
|
||||
"path": "/ci/recipes/troubleshooting",
|
||||
"id": "troubleshooting",
|
||||
"isExternal": false,
|
||||
"children": [
|
||||
{
|
||||
"name": "CI Execution Failed",
|
||||
"path": "/ci/recipes/troubleshooting/ci-execution-failed",
|
||||
"id": "ci-execution-failed",
|
||||
"isExternal": false,
|
||||
"children": [],
|
||||
"disableCollapsible": false
|
||||
}
|
||||
],
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "CI Execution Failed",
|
||||
"path": "/ci/recipes/troubleshooting/ci-execution-failed",
|
||||
"id": "ci-execution-failed",
|
||||
"isExternal": false,
|
||||
"children": [],
|
||||
"disableCollapsible": false
|
||||
},
|
||||
{
|
||||
"name": "Other",
|
||||
"path": "/ci/recipes/other",
|
||||
|
||||
@@ -6852,14 +6852,14 @@
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
"id": "angular-browser-target",
|
||||
"name": "Angular: The browserTarget",
|
||||
"description": "This document explains the role of the browserTarget in Angular projects with a Storybook configuration, and how the Storybook executors use it.",
|
||||
"id": "angular-project-build-config",
|
||||
"name": "Angular - The projectBuildConfig",
|
||||
"description": "This document explains the role of the projectBuildConfig in Angular projects with a Storybook configuration, and how the Storybook executors use it.",
|
||||
"mediaImage": "",
|
||||
"file": "shared/deprecated/storybook/angular-browser-target",
|
||||
"file": "shared/deprecated/storybook/angular-project-build-config",
|
||||
"itemList": [],
|
||||
"isExternal": false,
|
||||
"path": "/deprecated/storybook/angular-browser-target",
|
||||
"path": "/deprecated/storybook/angular-project-build-config",
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
@@ -7067,14 +7067,14 @@
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
"id": "angular-browser-target",
|
||||
"name": "Angular: The browserTarget",
|
||||
"description": "This document explains the role of the browserTarget in Angular projects with a Storybook configuration, and how the Storybook executors use it.",
|
||||
"id": "angular-project-build-config",
|
||||
"name": "Angular - The projectBuildConfig",
|
||||
"description": "This document explains the role of the projectBuildConfig in Angular projects with a Storybook configuration, and how the Storybook executors use it.",
|
||||
"mediaImage": "",
|
||||
"file": "shared/deprecated/storybook/angular-browser-target",
|
||||
"file": "shared/deprecated/storybook/angular-project-build-config",
|
||||
"itemList": [],
|
||||
"isExternal": false,
|
||||
"path": "/deprecated/storybook/angular-browser-target",
|
||||
"path": "/deprecated/storybook/angular-project-build-config",
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
@@ -7137,15 +7137,15 @@
|
||||
"path": "/deprecated/storybook/angular-storybook-targets",
|
||||
"tags": []
|
||||
},
|
||||
"/deprecated/storybook/angular-browser-target": {
|
||||
"id": "angular-browser-target",
|
||||
"name": "Angular: The browserTarget",
|
||||
"description": "This document explains the role of the browserTarget in Angular projects with a Storybook configuration, and how the Storybook executors use it.",
|
||||
"/deprecated/storybook/angular-project-build-config": {
|
||||
"id": "angular-project-build-config",
|
||||
"name": "Angular - The projectBuildConfig",
|
||||
"description": "This document explains the role of the projectBuildConfig in Angular projects with a Storybook configuration, and how the Storybook executors use it.",
|
||||
"mediaImage": "",
|
||||
"file": "shared/deprecated/storybook/angular-browser-target",
|
||||
"file": "shared/deprecated/storybook/angular-project-build-config",
|
||||
"itemList": [],
|
||||
"isExternal": false,
|
||||
"path": "/deprecated/storybook/angular-browser-target",
|
||||
"path": "/deprecated/storybook/angular-project-build-config",
|
||||
"tags": []
|
||||
},
|
||||
"/deprecated/storybook/migrate-webpack-final-angular": {
|
||||
|
||||
@@ -33,7 +33,7 @@ In any Nx workspace, you can install `@nx/angular` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/angular
|
||||
```
|
||||
|
||||
|
||||
@@ -105,6 +105,11 @@
|
||||
"type": "number",
|
||||
"description": "Enable and define the file watching poll time period in milliseconds."
|
||||
},
|
||||
"forceEsbuild": {
|
||||
"type": "boolean",
|
||||
"description": "Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option for the esbuild-based build system. _Note: this is only supported in Angular versions >= 16.1.0_.",
|
||||
"default": false
|
||||
},
|
||||
"buildLibsFromSource": {
|
||||
"type": "boolean",
|
||||
"description": "Read buildable libraries from source instead of building them separately. If not set, it will take the value specified in the `browserTarget` options, or it will default to `true` if it's also not set in the `browserTarget` options.",
|
||||
|
||||
@@ -29,7 +29,7 @@ In any Nx workspace, you can install `@nx/cypress` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/cypress
|
||||
```
|
||||
|
||||
@@ -75,6 +75,30 @@ The `@nx/cypress/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
|
||||
The `@nx/cypress/plugin` will automatically split your e2e tasks by file. You can read more about this feature [here](/ci/features/split-e2e-tasks).
|
||||
|
||||
To enable e2e task splitting, make sure there is a `ciWebServerCommand` property set in your `cypress.config.ts` file. It will look something like this:
|
||||
|
||||
```ts {% fileName="apps/my-project-e2e/cypress.config.ts" highlightLines=[13] %}
|
||||
import { defineConfig } from 'cypress';
|
||||
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
...nxE2EPreset(__filename, {
|
||||
cypressDir: 'src',
|
||||
bundler: 'vite',
|
||||
webServerCommands: {
|
||||
default: 'nx run my-project:serve',
|
||||
production: 'nx run my-project:preview',
|
||||
},
|
||||
ciWebServerCommand: 'nx run my-project:serve-static',
|
||||
}),
|
||||
baseUrl: 'http://localhost:4200',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Note: The `nxE2EPreset` is a collection of default settings, but is not necessary for task splitting.
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
|
||||
@@ -95,18 +119,18 @@ By default, when creating a new frontend application, Nx will use Cypress to cre
|
||||
nx g @nx/web:app frontend
|
||||
```
|
||||
|
||||
### Creating a Cypress E2E project for an existing project
|
||||
### Configure Cypress for an existing project
|
||||
|
||||
To generate an E2E project based on an existing project, run the following generator
|
||||
To configure Cypress for an existing project, run the following generator
|
||||
|
||||
```shell
|
||||
nx g @nx/cypress:configuration your-app-name-e2e --project=your-app-name
|
||||
nx g @nx/cypress:configuration --project=your-app-name
|
||||
```
|
||||
|
||||
Optionally, you can use the `--baseUrl` option if you don't want cypress plugin to serve `your-app-name`.
|
||||
Optionally, you can use the `--baseUrl` option if you don't want the Cypress plugin to serve `your-app-name`.
|
||||
|
||||
```shell
|
||||
nx g @nx/cypress:configuration your-app-name-e2e --baseUrl=http://localhost:4200
|
||||
nx g @nx/cypress:configuration --project=your-app-name --baseUrl=http://localhost:4200
|
||||
```
|
||||
|
||||
Replace `your-app-name` with the app's name as defined in your `tsconfig.base.json` file or the `name` property of your `package.json`.
|
||||
|
||||
@@ -36,7 +36,7 @@ In any Nx workspace, you can install `@nx/detox` by running the following comman
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/detox
|
||||
```
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ In any Nx workspace, you can install `@nx/esbuild` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/esbuild
|
||||
```
|
||||
|
||||
|
||||
@@ -13,10 +13,27 @@ Make sure to install the `@nx/eslint-plugin` version that matches the version of
|
||||
|
||||
In any Nx workspace, you can install `@nx/eslint-plugin` by running the following commands if the package is not already installed:
|
||||
|
||||
```shell
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/eslint-plugin
|
||||
```
|
||||
|
||||
This will install the correct version of `@nx/eslint-plugin`.
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
|
||||
Install the `@nx/eslint-plugin` package with your package manager.
|
||||
|
||||
```shell
|
||||
npm add -D @nx/eslint-plugin
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
{% /tabs %}
|
||||
|
||||
## Included plugins
|
||||
|
||||
The plugin contains the following rule configurations divided into sub-plugins.
|
||||
|
||||
@@ -13,7 +13,7 @@ In any Nx workspace, you can install `@nx/eslint` by running the following comma
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/eslint
|
||||
```
|
||||
|
||||
@@ -57,14 +57,23 @@ The `@nx/eslint/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
- The `targetName` option controls the name of the inferred ESLint tasks. The default name is `lint`.
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
{% tab label="Nx 17" %}
|
||||
|
||||
Install the `@nx/eslint` package with your package manager.
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
npm add -D @nx/eslint
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 17" %}
|
||||
|
||||
Install the `@nx/linter` package with your package manager.
|
||||
|
||||
```shell
|
||||
npm add -D @nx/linter
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ In any Nx workspace, you can install `@nx/expo` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/expo
|
||||
```
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
"items": { "type": "string" },
|
||||
"default": [],
|
||||
"description": "An array of npm packages to exclude."
|
||||
},
|
||||
"all": {
|
||||
"type": "boolean",
|
||||
"description": "Copy all dependencies and devDependencies from the workspace root package.json.",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"presets": []
|
||||
|
||||
@@ -22,7 +22,7 @@ In any Nx workspace, you can install `@nx/express` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/express
|
||||
```
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ In any Nx workspace, you can install `@nx/jest` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/jest
|
||||
```
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ In any Nx workspace, you can install `@nx/js` by running the following command:
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/js
|
||||
```
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ In any Nx workspace, you can install `@nx/nest` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/nest
|
||||
```
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ In any workspace, you can install `@nx/next` by running the following command:
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/next
|
||||
```
|
||||
|
||||
@@ -60,7 +60,8 @@ The `@nx/next/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
"options": {
|
||||
"buildTargetName": "build",
|
||||
"devTargetName": "dev",
|
||||
"startTargetName": "start"
|
||||
"startTargetName": "start",
|
||||
"serveStaticTargetName": "serve-static"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -70,6 +71,10 @@ The `@nx/next/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
- The `buildTargetName` option controls the name of Next.js' compilation task which compiles the application for production deployment. The default name is `build`.
|
||||
- The `devTargetName` option controls the name of Next.js' development serve task which starts the application in development mode. The default name is `dev`.
|
||||
- The `startTargetName` option controls the name of Next.js' production serve task which starts the application in production mode. The default name is `start`.
|
||||
- The `serveStaticTargetName` option controls the name of Next.js' static export task which exports the application to static HTML files. The default name is `serve-static`.
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
@@ -238,7 +243,7 @@ The library in `dist` is publishable to npm or a private registry.
|
||||
|
||||
### Static HTML Export
|
||||
|
||||
Next.js applications can be statically exported by changing th eoutput inside your Next.js configuration file.
|
||||
Next.js applications can be statically exported by changing the output inside your Next.js configuration file.
|
||||
|
||||
```js {% fileName="apps/my-next-app/next.config.js" %}
|
||||
const nextConfig = {
|
||||
@@ -246,9 +251,50 @@ const nextConfig = {
|
||||
nx: {
|
||||
svgr: false,
|
||||
},
|
||||
output: 'export',
|
||||
};
|
||||
```
|
||||
|
||||
After setting the output to `export`, you can run the `build` command to generate the static HTML files.
|
||||
|
||||
```shell
|
||||
nx build my-next-app
|
||||
```
|
||||
|
||||
You can then check your project folder for the `out` folder which contains the static HTML files.
|
||||
|
||||
```shell
|
||||
├── index.d.ts
|
||||
├── jest.config.ts
|
||||
├── next-env.d.ts
|
||||
├── next.config.js
|
||||
├── out
|
||||
├── project.json
|
||||
├── public
|
||||
├── specs
|
||||
├── src
|
||||
├── tsconfig.json
|
||||
└── tsconfig.spec.json
|
||||
```
|
||||
|
||||
#### E2E testing
|
||||
|
||||
You can perform end-to-end (E2E) testing on static HTML files using a test runner like Cypress. When you create a Next.js application, Nx automatically creates a `serve-static` target. This target is designed to serve the static HTML files produced by the build command.
|
||||
|
||||
This feature is particularly useful for testing in continuous integration (CI) pipelines, where resources may be constrained. Unlike the `dev` and `start` targets, `serve-static` does not require a Next.js server to operate, making it more efficient and faster by eliminating background processes, such as file change monitoring.
|
||||
|
||||
To utilize the `serve-static` target for testing, run the following command:
|
||||
|
||||
```shell
|
||||
nx serve-static my-next-app-e2e
|
||||
```
|
||||
|
||||
This command performs several actions:
|
||||
|
||||
1. It will build the Next.js application and generate the static HTML files.
|
||||
2. It will serve the static HTML files using a simple HTTP server.
|
||||
3. It will run the Cypress tests against the served static HTML files.
|
||||
|
||||
### Deploying Next.js Applications
|
||||
|
||||
Once you are ready to deploy your Next.js application, you have absolute freedom to choose any hosting provider that fits your needs.
|
||||
|
||||
@@ -13,7 +13,7 @@ In any Nx workspace, you can install `@nx/node` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/node
|
||||
```
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ Make sure to install the `@nx/nuxt` version that matches the version of `nx` in
|
||||
|
||||
In any Nx workspace, you can install `@nx/nuxt` by running the following command:
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/nuxt
|
||||
```
|
||||
|
||||
@@ -56,7 +56,9 @@ The `@nx/nuxt/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
"options": {
|
||||
"buildTargetName": "build",
|
||||
"testTargetName": "test",
|
||||
"serveTargetName": "serve"
|
||||
"serveTargetName": "serve",
|
||||
"buildStaticTargetName": "build-static",
|
||||
"serveStaticTargetName": "serve-static"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -65,6 +67,8 @@ The `@nx/nuxt/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
|
||||
- The `buildTargetName`, `testTargetName` and `serveTargetName` options control the names of the inferred Nuxt tasks. The default names are `build`, `test` and `serve`.
|
||||
|
||||
The `buildStaticTargetName` and `serveStaticTargetName` options control the names of the inferred Nuxt static tasks. The default names are `build-static` and `serve-static`.
|
||||
|
||||
## Using Nuxt
|
||||
|
||||
### Generate a new Nuxt app
|
||||
@@ -78,3 +82,23 @@ nx g @nx/nuxt:app my-app
|
||||
Once you are ready to deploy your Nuxt application, you have absolute freedom to choose any hosting provider that fits your needs.
|
||||
|
||||
We have detailed [how to deploy your Nuxt application to Vercel in a separate guide](/recipes/nuxt/deploy-nuxt-to-vercel).
|
||||
|
||||
### E2E testing
|
||||
|
||||
By default `nuxt` **does not** generate static HTML files when you run the `build` command. However, Nx provides a `build-static` target that you can use to generate static HTML files for your Nuxt application. Essentially, this target runs the `nuxt build --prerender` command to generate static HTML files.
|
||||
|
||||
To perform end-to-end (E2E) testing on static HTML files using a test runner like Cypress. When you create a Nuxt application, Nx automatically creates a `serve-static` target. This target is designed to serve the static HTML files produced by the `build-static` command.
|
||||
|
||||
This feature is particularly useful for testing in continuous integration (CI) pipelines, where resources may be constrained. Unlike the `serve` target, `serve-static` does not require a Nuxt's Nitro server to operate, making it more efficient and faster by eliminating background processes, such as file change monitoring.
|
||||
|
||||
To utilize the `serve-static` target for testing, run the following command:
|
||||
|
||||
```shell
|
||||
nx serve-static my-nuxt-app-e2e
|
||||
```
|
||||
|
||||
This command performs several actions:
|
||||
|
||||
1. It will build the Nuxt application and generate the static HTML files.
|
||||
2. It will serve the static HTML files using a simple HTTP server.
|
||||
3. It will run the Cypress tests against the served static HTML files.
|
||||
|
||||
@@ -24,7 +24,7 @@ In any Nx workspace, you can install `@nx/playwright` by running the following c
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/playwright
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ The `@nx/playwright/plugin` will automatically split your e2e tasks by file. You
|
||||
|
||||
Install the `@nx/playwright` package with your package manager.
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
npm add -D @nx/playwright
|
||||
```
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ In any Nx workspace, you can install `@nx/react-native` by running the following
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/react-native
|
||||
```
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
"items": { "type": "string" },
|
||||
"default": [],
|
||||
"description": "An array of npm packages to exclude."
|
||||
},
|
||||
"all": {
|
||||
"type": "boolean",
|
||||
"description": "Copy all dependencies and devDependencies from the workspace root package.json.",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"presets": []
|
||||
|
||||
@@ -27,7 +27,7 @@ In any Nx workspace, you can install `@nx/react` by running the following comman
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/react
|
||||
```
|
||||
|
||||
|
||||
@@ -69,7 +69,8 @@
|
||||
"e2eTestRunner": {
|
||||
"type": "string",
|
||||
"enum": ["cypress", "playwright", "none"],
|
||||
"description": "Test runner to use for end to end (e2e) tests.",
|
||||
"description": "Test runner to use for end to end (E2E) tests.",
|
||||
"x-prompt": "Which E2E test runner would you like to use?",
|
||||
"default": "cypress"
|
||||
},
|
||||
"host": {
|
||||
|
||||
@@ -94,7 +94,8 @@
|
||||
"e2eTestRunner": {
|
||||
"type": "string",
|
||||
"enum": ["cypress", "playwright", "none"],
|
||||
"description": "Test runner to use for end to end (e2e) tests.",
|
||||
"description": "Test runner to use for end to end (E2E) tests.",
|
||||
"x-prompt": "Which E2E test runner would you like to use?",
|
||||
"default": "cypress"
|
||||
},
|
||||
"tags": {
|
||||
@@ -164,7 +165,7 @@
|
||||
},
|
||||
"typescriptConfiguration": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
||||
"description": "Whether the module federation configuration and webpack configuration files should use TS. When --js is used, this flag is ignored.",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
|
||||
@@ -100,7 +100,8 @@
|
||||
"e2eTestRunner": {
|
||||
"type": "string",
|
||||
"enum": ["cypress", "playwright", "none"],
|
||||
"description": "Test runner to use for end to end (e2e) tests.",
|
||||
"description": "Test runner to use for end to end (E2E) tests.",
|
||||
"x-prompt": "Which E2E test runner would you like to use?",
|
||||
"default": "cypress"
|
||||
},
|
||||
"tags": {
|
||||
@@ -163,7 +164,7 @@
|
||||
},
|
||||
"typescriptConfiguration": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
||||
"description": "Whether the module federation configuration and webpack configuration files should use TS. When --js is used, this flag is ignored.",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
|
||||
@@ -28,7 +28,7 @@ In any Nx workspace, you can install `@nx/remix` by running the following comman
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/remix
|
||||
```
|
||||
|
||||
@@ -89,7 +89,7 @@ The command below uses the `as-provided` directory flag behavior, which is the d
|
||||
{% /callout %}
|
||||
|
||||
```{% command="nx g @nx/remix:app myapp --directory=apps/myapp" path="~/acme" %}
|
||||
> NX Generating @nx/remix:application
|
||||
NX Generating @nx/remix:application
|
||||
|
||||
✔ What unit test runner should be used? · vitest
|
||||
|
||||
@@ -135,9 +135,9 @@ Building Remix app in production mode...
|
||||
|
||||
Built in 857ms
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project myapp (3s)
|
||||
NX Successfully ran target build for project myapp (3s)
|
||||
```
|
||||
|
||||
2. To serve your application for use during development run:
|
||||
@@ -155,18 +155,18 @@ Remix App Server started at http://localhost:3000 (http://192.168.0.14:3000)
|
||||
```{% command="nx test myapp" path="~/acme" %}
|
||||
> nx run myapp:test
|
||||
|
||||
RUN v0.31.4 /Users/columferry/dev/nrwl/issues/remixguide/acme/apps/myapp
|
||||
RUN v0.31.4 /Users/columferry/dev/nrwl/issues/remixguide/acme/apps/myapp
|
||||
stderr | app/routes/index.spec.ts > test > should render
|
||||
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
|
||||
✓ app/routes/index.spec.ts (1 test) 10ms
|
||||
Test Files 1 passed (1)
|
||||
Tests 1 passed (1)
|
||||
Start at 16:15:45
|
||||
Duration 1.20s (transform 51ms, setup 139ms, collect 180ms, tests 10ms, environment 379ms, prepare 103ms)
|
||||
✓ app/routes/index.spec.ts (1 test) 10ms
|
||||
Test Files 1 passed (1)
|
||||
Tests 1 passed (1)
|
||||
Start at 16:15:45
|
||||
Duration 1.20s (transform 51ms, setup 139ms, collect 180ms, tests 10ms, environment 379ms, prepare 103ms)
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target test for project myapp (2s)
|
||||
NX Successfully ran target test for project myapp (2s)
|
||||
```
|
||||
|
||||
## Generating an Nx Library
|
||||
@@ -176,7 +176,7 @@ When developing your application, it often makes sense to split your codebase in
|
||||
To generate a library to use in your Remix application run:
|
||||
|
||||
```{% command="nx g @nx/remix:lib login --directory=libs/login" path="~/acme" %}
|
||||
> NX Generating @nx/remix:library
|
||||
NX Generating @nx/remix:library
|
||||
|
||||
✔ What test runner should be used? · vitest
|
||||
UPDATE nx.json
|
||||
@@ -223,7 +223,7 @@ You can also run test on your library:
|
||||
To generate a route for your application:
|
||||
|
||||
```{% command="nx g @nx/remix:route admin --path=apps/myapp/app/routes" path="~/acme" %}
|
||||
> NX Generating @nx/remix:route
|
||||
NX Generating @nx/remix:route
|
||||
|
||||
CREATE apps/myapp/app/routes/admin.tsx
|
||||
CREATE apps/myapp/app/styles/admin.css
|
||||
@@ -236,7 +236,7 @@ To use a Route Loader where the logic lives in your library, follow the steps be
|
||||
1. Generate a loader for your route:
|
||||
|
||||
```{% command="nx g @nx/remix:loader admin --path=apps/myapp/app/routes" path="~/acme" %}
|
||||
> NX Generating @nx/remix:loader
|
||||
NX Generating @nx/remix:loader
|
||||
|
||||
UPDATE apps/myapp/app/routes/admin.tsx
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
},
|
||||
"e2eTestRunner": {
|
||||
"type": "string",
|
||||
"enum": ["cypress", "none"],
|
||||
"enum": ["cypress", "playwright", "none"],
|
||||
"default": "cypress",
|
||||
"description": "Test runner to use for e2e tests"
|
||||
},
|
||||
|
||||
@@ -20,7 +20,7 @@ In any Nx workspace, you can install `@nx/storybook` by running the following co
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/storybook
|
||||
```
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
},
|
||||
"additionalProperties": true,
|
||||
"required": ["configDir"],
|
||||
"examplesFile": "---\ntitle: Storybook builder executor examples\ndescription: This page contains examples for the @nx/storybook:build executor.\n---\n\n`project.json`:\n\n```json\n//...\n\"ui\": {\n \"targets\": {\n //...\n \"build-storybook\": {\n \"executor\": \"@nx/storybook:build\",\n \"outputs\": [\"{options.outputDir}\"],\n \"options\": {\n \"outputDir\": \"dist/storybook/ui\",\n \"configDir\": \"libs/ui/.storybook\"\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n }\n}\n```\n\n```bash\nnx run ui:build-storybook\n```\n\n## Examples\n\n### For non-Angular projects\n\n{% tabs %}\n{% tab label=\"Working in docsMode\" %}\n\nYou can work in docs mode, building a documentation-only site, by setting the `docsMode` option to `true` and using the `@storybook/addon-docs` addon.\n\nRead more on the [Storybook documentation page for `addon-docs`](https://storybook.js.org/addons/@storybook/addon-docs).\n\n```json\n\"storybook\": {\n \"executor\": \"@nx/storybook:build\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"docsMode\": true\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% /tabs %}\n\n### For Angular projects\n\n{% tabs %}\n{% tab label=\"Default configuration\" %}\n\nThis is the default configuration for Angular projects using Storybook. You can see that it uses the native `@storybook/angular:build-storybook` executor. You can read more about the configuration options at the relevant [Storybook documentation page](https://storybook.js.org/docs/angular/get-started/install).\n\n```json\n\"build-storybook\": {\n \"executor\": \"@storybook/angular:build-storybook\",\n \"outputs\": [\"{options.outputDir}\"],\n \"options\": {\n \"outputDir\": \"dist/storybook/ngapp\",\n \"configDir\": \"apps/ngapp/.storybook\",\n \"browserTarget\": \"ngapp:build\",\n \"compodoc\": false\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Changing the browserTarget\" %}\n\nYou can set the [`browserTarget`](/deprecated/storybook/angular-browser-target) to use `build-storybook` as the builder. This is most useful in the cases where your project does not have a `build` target.\n\n```json\n\"build-storybook\": {\n \"executor\": \"@storybook/angular:build-storybook\",\n \"outputs\": [\"{options.outputDir}\"],\n \"options\": {\n \"outputDir\": \"dist/storybook/ngapp\",\n \"configDir\": \"apps/ngapp/.storybook\",\n \"browserTarget\": \"ngapp:build-storybook\",\n \"compodoc\": false\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Adding styles\" %}\n\nYou can add paths to stylesheets to be included in the Storybook build by using the `styles` array. You can also add `stylePreprocessorOptions`, much like you would do in the Angular builder. You can read more in our guide about [styles and preprocessor options for Storybook](/recipes/storybook/angular-configuring-styles).\n\n```json\n\"build-storybook\": {\n \"executor\": \"@storybook/angular:build-storybook\",\n \"outputs\": [\"{options.outputDir}\"],\n \"options\": {\n \"outputDir\": \"dist/storybook/ngapp\",\n \"configDir\": \"apps/ngapp/.storybook\",\n \"browserTarget\": \"ngapp:build-storybook\",\n \"compodoc\": false,\n \"styles\": [\"some-styles.css\"],\n \"stylePreprocessorOptions\": {\n \"includePaths\": [\"some-style-paths\"]\n }\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% /tabs %}\n"
|
||||
"examplesFile": "---\ntitle: Storybook builder executor examples\ndescription: This page contains examples for the @nx/storybook:build executor.\n---\n\n`project.json`:\n\n```json\n//...\n\"ui\": {\n \"targets\": {\n //...\n \"build-storybook\": {\n \"executor\": \"@nx/storybook:build\",\n \"outputs\": [\"{options.outputDir}\"],\n \"options\": {\n \"outputDir\": \"dist/storybook/ui\",\n \"configDir\": \"libs/ui/.storybook\"\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n }\n}\n```\n\n```bash\nnx run ui:build-storybook\n```\n\n## Examples\n\n### For non-Angular projects\n\n{% tabs %}\n{% tab label=\"Working in docsMode\" %}\n\nYou can work in docs mode, building a documentation-only site, by setting the `docsMode` option to `true` and using the `@storybook/addon-docs` addon.\n\nRead more on the [Storybook documentation page for `addon-docs`](https://storybook.js.org/addons/@storybook/addon-docs).\n\n```json\n\"storybook\": {\n \"executor\": \"@nx/storybook:build\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"docsMode\": true\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% /tabs %}\n\n### For Angular projects\n\n{% tabs %}\n{% tab label=\"Default configuration\" %}\n\nThis is the default configuration for Angular projects using Storybook. You can see that it uses the native `@storybook/angular:build-storybook` executor. You can read more about the configuration options at the relevant [Storybook documentation page](https://storybook.js.org/docs/angular/get-started/install).\n\n```json\n\"build-storybook\": {\n \"executor\": \"@storybook/angular:build-storybook\",\n \"outputs\": [\"{options.outputDir}\"],\n \"options\": {\n \"outputDir\": \"dist/storybook/ngapp\",\n \"configDir\": \"apps/ngapp/.storybook\",\n \"browserTarget\": \"ngapp:build\",\n \"compodoc\": false\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Changing the browserTarget\" %}\n\nYou can set the `browserTarget` to use `build-storybook` as the builder. This is most useful in the cases where your project does not have a `build` target. Read more about the `browserTarget` in the [Set up Storybook for Angular Projects](/recipes/storybook/overview-angular) recipe.\n\n```json\n\"build-storybook\": {\n \"executor\": \"@storybook/angular:build-storybook\",\n \"outputs\": [\"{options.outputDir}\"],\n \"options\": {\n \"outputDir\": \"dist/storybook/ngapp\",\n \"configDir\": \"apps/ngapp/.storybook\",\n \"browserTarget\": \"ngapp:build-storybook\",\n \"compodoc\": false\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Adding styles\" %}\n\nYou can add paths to stylesheets to be included in the Storybook build by using the `styles` array. You can also add `stylePreprocessorOptions`, much like you would do in the Angular builder. You can read more in our guide about [styles and preprocessor options for Storybook](/recipes/storybook/angular-configuring-styles).\n\n```json\n\"build-storybook\": {\n \"executor\": \"@storybook/angular:build-storybook\",\n \"outputs\": [\"{options.outputDir}\"],\n \"options\": {\n \"outputDir\": \"dist/storybook/ngapp\",\n \"configDir\": \"apps/ngapp/.storybook\",\n \"browserTarget\": \"ngapp:build-storybook\",\n \"compodoc\": false,\n \"styles\": [\"some-styles.css\"],\n \"stylePreprocessorOptions\": {\n \"includePaths\": [\"some-style-paths\"]\n }\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% /tabs %}\n"
|
||||
},
|
||||
"description": "Build Storybook.",
|
||||
"aliases": [],
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
"additionalProperties": true,
|
||||
"definitions": {},
|
||||
"required": ["configDir"],
|
||||
"examplesFile": "---\ntitle: Storybook dev server executor examples\ndescription: This page contains examples for the @nx/storybook:storybook executor.\n---\n\n`project.json`:\n\n```json\n//...\n\"ui\": {\n \"targets\": {\n //...\n \"storybook\": {\n \"executor\": \"@nx/storybook:storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\"\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n },\n }\n}\n```\n\n```bash\nnx run ui:storybook\n```\n\n## Examples\n\n### For non-Angular projects\n\n{% tabs %}\n{% tab label=\"Working in docsMode\" %}\n\nYou can work in docs mode, building a documentation-only site, by setting the `docsMode` option to `true` and using the `@storybook/addon-docs` addon.\n\nRead more on the [Storybook documentation page for `addon-docs`](https://storybook.js.org/addons/@storybook/addon-docs).\n\n```json\n\"storybook\": {\n \"executor\": \"@nx/storybook:storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"docsMode\": true\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% /tabs %}\n\n### For Angular projects\n\n{% tabs %}\n{% tab label=\"Default configuration\" %}\n\nThis is the default configuration for Angular projects using Storybook. You can see that it uses the native `@storybook/angular:start-storybook` executor. You can read more about the configuration options at the relevant [Storybook documentation page](https://storybook.js.org/docs/angular/get-started/install).\n\n```json\n\"storybook\": {\n \"executor\": \"@storybook/angular:start-storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"browserTarget\": \"ui:build\",\n \"compodoc\": false\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n},\n```\n\n{% /tab %}\n{% tab label=\"Changing the browserTarget\" %}\n\nYou can set the [`browserTarget`](/deprecated/storybook/angular-browser-target) to use `build-storybook` as the builder. This is most useful in the cases where your project does not have a `build` target.\n\n```json\n\"storybook\": {\n \"executor\": \"@storybook/angular:start-storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"browserTarget\": \"ui:build-storybook\",\n \"compodoc\": false\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n},\n```\n\n{% /tab %}\n\n{% tab label=\"Adding styles\" %}\n\nYou can add paths to stylesheets to be included in the Storybook build by using the `styles` array. You can also add `stylePreprocessorOptions`, much like you would do in the Angular builder. You can read more in our guide about [styles and preprocessor options for Storybook](/recipes/storybook/angular-configuring-styles).\n\n```json\n\"storybook\": {\n \"executor\": \"@storybook/angular:start-storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"browserTarget\": \"ui:build\",\n \"compodoc\": false,\n \"styles\": [\"some-styles.css\"],\n \"stylePreprocessorOptions\": {\n \"includePaths\": [\"some-style-paths\"]\n }\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n},\n```\n\n{% /tab %}\n\n{% /tabs %}\n"
|
||||
"examplesFile": "---\ntitle: Storybook dev server executor examples\ndescription: This page contains examples for the @nx/storybook:storybook executor.\n---\n\n`project.json`:\n\n```json\n//...\n\"ui\": {\n \"targets\": {\n //...\n \"storybook\": {\n \"executor\": \"@nx/storybook:storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\"\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n },\n }\n}\n```\n\n```bash\nnx run ui:storybook\n```\n\n## Examples\n\n### For non-Angular projects\n\n{% tabs %}\n{% tab label=\"Working in docsMode\" %}\n\nYou can work in docs mode, building a documentation-only site, by setting the `docsMode` option to `true` and using the `@storybook/addon-docs` addon.\n\nRead more on the [Storybook documentation page for `addon-docs`](https://storybook.js.org/addons/@storybook/addon-docs).\n\n```json\n\"storybook\": {\n \"executor\": \"@nx/storybook:storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"docsMode\": true\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% /tabs %}\n\n### For Angular projects\n\n{% tabs %}\n{% tab label=\"Default configuration\" %}\n\nThis is the default configuration for Angular projects using Storybook. You can see that it uses the native `@storybook/angular:start-storybook` executor. You can read more about the configuration options at the relevant [Storybook documentation page](https://storybook.js.org/docs/angular/get-started/install).\n\n```json\n\"storybook\": {\n \"executor\": \"@storybook/angular:start-storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"browserTarget\": \"ui:build\",\n \"compodoc\": false\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n},\n```\n\n{% /tab %}\n{% tab label=\"Changing the browserTarget\" %}\n\nYou can set the `browserTarget` to use `build-storybook` as the builder. This is most useful in the cases where your project does not have a `build` target. Read more about the `browserTarget` in the [Set up Storybook for Angular Projects](/recipes/storybook/overview-angular) recipe.\n\n```json\n\"storybook\": {\n \"executor\": \"@storybook/angular:start-storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"browserTarget\": \"ui:build-storybook\",\n \"compodoc\": false\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n},\n```\n\n{% /tab %}\n\n{% tab label=\"Adding styles\" %}\n\nYou can add paths to stylesheets to be included in the Storybook build by using the `styles` array. You can also add `stylePreprocessorOptions`, much like you would do in the Angular builder. You can read more in our guide about [styles and preprocessor options for Storybook](/recipes/storybook/angular-configuring-styles).\n\n```json\n\"storybook\": {\n \"executor\": \"@storybook/angular:start-storybook\",\n \"options\": {\n \"port\": 4400,\n \"configDir\": \"libs/ui/.storybook\",\n \"browserTarget\": \"ui:build\",\n \"compodoc\": false,\n \"styles\": [\"some-styles.css\"],\n \"stylePreprocessorOptions\": {\n \"includePaths\": [\"some-style-paths\"]\n }\n },\n \"configurations\": {\n \"ci\": {\n \"quiet\": true\n }\n }\n},\n```\n\n{% /tab %}\n\n{% /tabs %}\n"
|
||||
},
|
||||
"description": "Serve Storybook.",
|
||||
"aliases": [],
|
||||
|
||||
@@ -35,7 +35,7 @@ In any Nx workspace, you can install `@nx/vite` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/vite
|
||||
```
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"type": "string",
|
||||
"description": "Directory to write coverage report to."
|
||||
},
|
||||
"mode": { "type": "string", "description": "Mode for Vite." },
|
||||
"testFiles": {
|
||||
"aliases": ["testFile"],
|
||||
"type": "array",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -26,7 +26,7 @@ In any Nx workspace, you can install `@nx/vue` by running the following command:
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/vue
|
||||
```
|
||||
|
||||
@@ -37,7 +37,7 @@ This will install the correct version of `@nx/vue`.
|
||||
|
||||
Install the `@nx/vue` package with your package manager.
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
npm add -D @nx/vue
|
||||
```
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ In any Nx workspace, you can install `@nx/web` by running the following command:
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/web
|
||||
```
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ In any Nx workspace, you can install `@nx/webpack` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/webpack
|
||||
```
|
||||
|
||||
|
||||
@@ -11,5 +11,6 @@ and the version of NodeJS that we tested it against.
|
||||
| 13.x | 10.x, 12.x, 14.x | ~4.6.2 |
|
||||
| 14.x | 12.x, 14.x, 16.x | ~4.7.2 |
|
||||
| 15.x | 14.x, 16.x, 18.x | ~5.0.0 |
|
||||
| 16.x (previous) | 16.x, 18.x, 20.x | ~5.1.0 |
|
||||
| 17.x (latest) | 18.x, 20.x | ~5.1.0 |
|
||||
| 16.x | 16.x, 18.x, 20.x | ~5.1.0 |
|
||||
| 17.x (previous) | 18.x, 20.x | ~5.1.0 |
|
||||
| 18.x (latest) | 18.x, 20.x | ~5.1.0 |
|
||||
|
||||
+17
-5
@@ -1429,10 +1429,10 @@
|
||||
"file": "shared/deprecated/storybook/angular-storybook-targets"
|
||||
},
|
||||
{
|
||||
"id": "angular-browser-target",
|
||||
"name": "Angular: The browserTarget",
|
||||
"description": "This document explains the role of the browserTarget in Angular projects with a Storybook configuration, and how the Storybook executors use it.",
|
||||
"file": "shared/deprecated/storybook/angular-browser-target"
|
||||
"id": "angular-project-build-config",
|
||||
"name": "Angular - The projectBuildConfig",
|
||||
"description": "This document explains the role of the projectBuildConfig in Angular projects with a Storybook configuration, and how the Storybook executors use it.",
|
||||
"file": "shared/deprecated/storybook/angular-project-build-config"
|
||||
},
|
||||
{
|
||||
"id": "migrate-webpack-final-angular",
|
||||
@@ -1712,7 +1712,7 @@
|
||||
"file": "nx-cloud/features/dynamic-agents"
|
||||
},
|
||||
{
|
||||
"name": "Automatically Split E2E Tasks",
|
||||
"name": "Automatically Split E2E Tasks (TestAtomizer)",
|
||||
"id": "split-e2e-tasks",
|
||||
"file": "nx-cloud/features/split-e2e-tasks"
|
||||
},
|
||||
@@ -1899,6 +1899,18 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Troubleshooting",
|
||||
"id": "troubleshooting",
|
||||
"description": "Learn how to solve common issues in Nx Cloud.",
|
||||
"itemList": [
|
||||
{
|
||||
"name": "CI Execution Failed",
|
||||
"id": "ci-execution-failed",
|
||||
"file": "nx-cloud/troubleshooting/ci-execution-failed"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Other",
|
||||
"id": "other",
|
||||
|
||||
@@ -10,7 +10,7 @@ The standard way to set up [Nx Agents](/ci/features/distribute-task-execution) i
|
||||
|
||||
```yaml {% fileName=".nx/workflows/dynamic-changesets.yaml" %}
|
||||
distribute-on:
|
||||
small-changeset: 1 linux-medium-js
|
||||
small-changeset: 3 linux-medium-js
|
||||
medium-changeset: 6 linux-medium-js
|
||||
large-changeset: 10 linux-medium-js
|
||||
```
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 281 KiB |
@@ -8,14 +8,20 @@ Nx is perfectly positioned to detect which tasks are flaky and automatically re-
|
||||
|
||||
Nx creates a hash of all the inputs for a task whenever it is run. If Nx ever encounters a task that fails with a particular set of inputs and then succeeds with those same inputs, Nx knows for a fact that the task is flaky. Nx can't know with certainty when the task has been fixed to no longer be flaky, so if a particular task has no flakiness incidents for 2 weeks, the `flaky` flag is removed for that task.
|
||||
|
||||

|
||||
|
||||
In this image, the `e2e-ci--src/e2e/app.cy.ts` task is a flaky task that has been automatically retried once. There is a `1 retry` indicator to show that it has been retried and, once expanded, you can see tabs that contain the logs for `Attempt 1` and `Attempt 2`. With this UI, you can easily compare the output between a successful and unsuccessful run of a flaky task.
|
||||
|
||||
## Manually Mark a Task as Flaky or Not Flaky
|
||||
|
||||
If you need to manually mark a task as flaky or not flaky, you can do so from the run details screen. Flaky tasks will have a button that says `Mark task as no longer flaky` and failed tasks that are not flaky will have a button that says `Mark task as likely flaky`. Using these buttons, you can ensure that Nx Cloud treats tasks in the appropriate way.
|
||||
|
||||

|
||||
If you suspect that a task is flaky, but Nx has not confirmed it yet, you can manually mark it as `likely flaky` from the run details screen. Failed tasks that are not flaky will have a button that says `Mark task as likely flaky`.
|
||||
|
||||

|
||||
|
||||
Once you've resolved the issue that caused a task to be flaky, you can immediately mark the task as not flaky by clicking on `Mark task as no longer flaky` on the same run details screen.
|
||||
|
||||

|
||||
|
||||
## Re-run Flaky Tasks
|
||||
|
||||
When a flaky task fails in CI with [distributed task execution](/ci/features/distribute-task-execution) enabled, Nx will automatically send that task to a different agent and run it again (up to 2 tries in total). Its important to run the task on a different agent to ensure that the agent itself or the other tasks that were run on that agent are not the reason for the flakiness.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 66 KiB |
@@ -11,14 +11,14 @@ To enable automatically split e2e tasks, you need to turn on [inferred tasks](/c
|
||||
{% tabs %}
|
||||
{% tab label="Cypress" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/cypress
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Playwright" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/playwright
|
||||
```
|
||||
|
||||
@@ -33,15 +33,301 @@ If you are already using the `@nx/cypress` or `@nx/playwright` plugin, you need
|
||||
|
||||
## Usage
|
||||
|
||||
You can view the available tasks in the graph:
|
||||
You can view the available tasks for your project in the project detail view:
|
||||
|
||||
```shell
|
||||
nx graph
|
||||
nx show project myproject-e2e --web
|
||||
```
|
||||
|
||||
{% project-details title="Project Details View" height="100px" %}
|
||||
|
||||
```json
|
||||
{
|
||||
"project": {
|
||||
"name": "admin-e2e",
|
||||
"data": {
|
||||
"root": "apps/admin-e2e",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"cache": true,
|
||||
"inputs": ["default", "^production"],
|
||||
"outputs": [
|
||||
"{workspaceRoot}/dist/cypress/apps/admin-e2e/videos",
|
||||
"{workspaceRoot}/dist/cypress/apps/admin-e2e/screenshots"
|
||||
],
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["^build"],
|
||||
"options": {
|
||||
"cwd": "apps/admin-e2e",
|
||||
"command": "cypress run"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"command": "cypress run --env webServerCommand=\"nx run admin:preview\""
|
||||
}
|
||||
}
|
||||
},
|
||||
"e2e-ci--src/e2e/app.cy.ts": {
|
||||
"outputs": [
|
||||
"{workspaceRoot}/dist/cypress/apps/admin-e2e/videos",
|
||||
"{workspaceRoot}/dist/cypress/apps/admin-e2e/screenshots"
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
{
|
||||
"externalDependencies": ["cypress"]
|
||||
}
|
||||
],
|
||||
"cache": true,
|
||||
"options": {
|
||||
"cwd": "apps/admin-e2e",
|
||||
"command": "cypress run --env webServerCommand=\"nx run admin:serve-static\" --spec src/e2e/app.cy.ts"
|
||||
},
|
||||
"executor": "nx:run-commands",
|
||||
"configurations": {}
|
||||
},
|
||||
"e2e-ci--src/e2e/login.cy.ts": {
|
||||
"outputs": [
|
||||
"{workspaceRoot}/dist/cypress/apps/admin-e2e/videos",
|
||||
"{workspaceRoot}/dist/cypress/apps/admin-e2e/screenshots"
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
{
|
||||
"externalDependencies": ["cypress"]
|
||||
}
|
||||
],
|
||||
"cache": true,
|
||||
"options": {
|
||||
"cwd": "apps/admin-e2e",
|
||||
"command": "cypress run --env webServerCommand=\"nx run admin:serve-static\" --spec src/e2e/login.cy.ts"
|
||||
},
|
||||
"executor": "nx:run-commands",
|
||||
"configurations": {}
|
||||
},
|
||||
"e2e-ci": {
|
||||
"executor": "nx:noop",
|
||||
"cache": true,
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
{
|
||||
"externalDependencies": ["cypress"]
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
"{workspaceRoot}/dist/cypress/apps/admin-e2e/videos",
|
||||
"{workspaceRoot}/dist/cypress/apps/admin-e2e/screenshots"
|
||||
],
|
||||
"dependsOn": [
|
||||
{
|
||||
"target": "e2e-ci--src/e2e/app.cy.ts",
|
||||
"projects": "self",
|
||||
"params": "forward"
|
||||
},
|
||||
{
|
||||
"target": "e2e-ci--src/e2e/login.cy.ts",
|
||||
"projects": "self",
|
||||
"params": "forward"
|
||||
}
|
||||
],
|
||||
"options": {},
|
||||
"configurations": {}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
|
||||
"cache": true,
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {},
|
||||
"configurations": {}
|
||||
}
|
||||
},
|
||||
"name": "admin-e2e",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "apps/admin-e2e/src",
|
||||
"tags": [],
|
||||
"implicitDependencies": ["admin"]
|
||||
}
|
||||
},
|
||||
"sourceMap": {
|
||||
"root": ["apps/admin-e2e/project.json", "nx/core/project-json"],
|
||||
"projectType": ["apps/admin-e2e/project.json", "nx/core/project-json"],
|
||||
"targets": ["apps/admin-e2e/project.json", "nx/core/project-json"],
|
||||
"targets.e2e": ["apps/admin-e2e/project.json", "nx/core/target-defaults"],
|
||||
"targets.e2e.options": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e.cache": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/target-defaults"
|
||||
],
|
||||
"targets.e2e.inputs": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/target-defaults"
|
||||
],
|
||||
"targets.e2e.outputs": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e.configurations": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e.executor": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e.options.cwd": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e.options.command": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e.configurations.production": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e.configurations.production.command": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/app.cy.ts": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/app.cy.ts.outputs": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/app.cy.ts.inputs": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/app.cy.ts.cache": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/app.cy.ts.options": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/app.cy.ts.executor": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/app.cy.ts.options.cwd": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/app.cy.ts.options.command": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/login.cy.ts": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/login.cy.ts.outputs": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/login.cy.ts.inputs": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/login.cy.ts.cache": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/login.cy.ts.options": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/login.cy.ts.executor": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/login.cy.ts.options.cwd": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci--src/e2e/login.cy.ts.options.command": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci.executor": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci.cache": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci.inputs": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci.outputs": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e-ci.dependsOn": [
|
||||
"apps/admin-e2e/cypress.config.ts",
|
||||
"@nx/cypress/plugin"
|
||||
],
|
||||
"targets.e2e.dependsOn": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/target-defaults"
|
||||
],
|
||||
"targets.lint": ["apps/admin-e2e/project.json", "nx/core/project-json"],
|
||||
"targets.lint.executor": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/project-json"
|
||||
],
|
||||
"targets.lint.inputs": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/target-defaults"
|
||||
],
|
||||
"targets.lint.cache": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/target-defaults"
|
||||
],
|
||||
"name": ["apps/admin-e2e/project.json", "nx/core/project-json"],
|
||||
"$schema": ["apps/admin-e2e/project.json", "nx/core/project-json"],
|
||||
"sourceRoot": ["apps/admin-e2e/project.json", "nx/core/project-json"],
|
||||
"tags": ["apps/admin-e2e/project.json", "nx/core/project-json"],
|
||||
"implicitDependencies": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/project-json"
|
||||
],
|
||||
"implicitDependencies.admin": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/project-json"
|
||||
],
|
||||
"targets.lint.outputs": [
|
||||
"apps/admin-e2e/project.json",
|
||||
"nx/core/project-json"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{% /project-details %}
|
||||
|
||||
You'll see that there are tasks named `e2e`, `e2e-ci` and a task for each e2e test file.
|
||||
|
||||
Developers can run all e2e tests locally the same way as usual:
|
||||
Developers can run all e2e tests locally with the `e2e` target:
|
||||
|
||||
```shell
|
||||
nx e2e my-project-e2e
|
||||
@@ -55,8 +341,16 @@ nx e2e-ci my-project-e2e
|
||||
|
||||
## Benefits
|
||||
|
||||
Smaller e2e tasks enable the following benefits:
|
||||
With more granular e2e tasks, all the other features of Nx become more powerful. Let's imagine a scenario where there are 10 spec files in a single e2e project and each spec file takes 3 minutes to run.
|
||||
|
||||
- Nx's cache can be used for all the e2e tasks that succeeded and only the failed tasks need to be re-run
|
||||
- Distributed Task Execution allows your e2e tests to be run on multiple machines simultaneously, which reduces the total time of the CI pipeline
|
||||
- Nx Agents can [automatically re-run failed flaky e2e tests](/ci/features/flaky-tasks) on a separate agent without a developer needing to manually re-run the CI pipeline
|
||||
### Improved Caching
|
||||
|
||||
[Nx's cache](/ci/features/remote-cache) can be used for all the individual e2e tasks that succeeded and only the failed tasks need to be re-run. Without e2e task splitting, a single spec file failing would force you to re-run all the e2e tests for the project, which would take 30 minutes. With e2e task splitting, a single spec file that fails can be re-run in 3 minutes and the other successful spec file results can be retrieved from the cache.
|
||||
|
||||
### Better Distribution
|
||||
|
||||
[Distributed task execution](/ci/features/distribute-task-execution) allows your e2e tests to be run on multiple machines simultaneously, which reduces the total time of the CI pipeline. Without e2e task splitting, the CI pipeline has to take at least 30 minutes to complete because the one e2e task needs that long to finish. With e2e task splitting, a fully distributed pipeline with 10 agents could finish in 3 minutes.
|
||||
|
||||
### More Precise Flaky Task Identification
|
||||
|
||||
Nx Agents [automatically re-run failed flaky e2e tests](/ci/features/flaky-tasks) on a separate agent without a developer needing to manually re-run the CI pipeline. Leveraging e2e task splitting, Nx identifies the specific flaky test file - this way you can quickly fix the offending test file. Without e2e splitting, Nx identifies that at least one of the e2e tests are flaky - requiring you to find the flaky test on your own.
|
||||
|
||||
@@ -10,8 +10,8 @@ This is an example of a launch template using all built-in features:
|
||||
```yaml
|
||||
launch-templates:
|
||||
my-linux-medium-js:
|
||||
resourceClass: ''
|
||||
image: 'ubuntu22.04-node20.9-v1'
|
||||
resourceClass: 'docker_linux_amd64/medium'
|
||||
image: 'ubuntu22.04-node20.9-v3'
|
||||
env: MY_ENV_VAR=shared
|
||||
init-steps:
|
||||
- name: Checkout # using a reusable step
|
||||
@@ -47,6 +47,7 @@ The following resource classes are available:
|
||||
- `docker_linux_amd64/large+`
|
||||
- `docker_linux_amd64/extra_large`
|
||||
- `docker_linux_amd64/extra_large+`
|
||||
- `windows/medium`
|
||||
|
||||
See their detailed description and pricing at [nx.app/pricing](https://nx.app/pricing).
|
||||
|
||||
@@ -58,6 +59,11 @@ The following images are available:
|
||||
- `ubuntu22.04-node20.9-withDind-v1`
|
||||
- `ubuntu22.04-node20.9-v2`
|
||||
- `ubuntu22.04-node20.9-withDind-v2`
|
||||
- `ubuntu22.04-node20.9-v3`
|
||||
- `ubuntu22.04-node20.9-withDind-v3`
|
||||
- `windows-2022`
|
||||
|
||||
_Note: Windows-based images can only run on Windows-based resource classes._
|
||||
|
||||
Enterprise accounts can use custom images.
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ You can also define the configuration in a file and reference it as follows:
|
||||
|
||||
```yaml {% fileName=".nx/workflows/dynamic-changesets.yaml" %}
|
||||
distribute-on:
|
||||
small-changeset: 1 linux-medium-js
|
||||
small-changeset: 3 linux-medium-js
|
||||
medium-changeset: 6 linux-medium-js
|
||||
large-changeset: 10 linux-medium-js
|
||||
```
|
||||
@@ -86,7 +86,7 @@ individual commands as follows:
|
||||
|
||||
## npx nx-cloud stop-all-agents
|
||||
|
||||
Same as `npx nx-cloud complete-ci-run` and `npx nx-cloud complete-run-group`.
|
||||
Same as `npx nx-cloud complete-ci-run`.
|
||||
|
||||
This command tells Nx Cloud to terminate all agents associated with this CI pipeline execution.
|
||||
Invoking this command is not needed anymore. New versions of Nx Cloud can track when the main job terminates
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
# Understanding 'CI Execution Failed'
|
||||
|
||||
## Task Runner-Related
|
||||
|
||||
### No additional tasks detected
|
||||
|
||||
Nx Cloud is not aware of any more tasks to distribute. This can occur if Nx Cloud thinks it is done receiving tasks to distribute and all existing tasks have been completed.
|
||||
|
||||
If you are receiving this error before your full pipeline has completed, consider using [--stop-agents-after](https://nx.dev/ci/reference/nx-cloud-cli#stopagentsafter) with the target set to the last target run in your pipeline.
|
||||
|
||||
### The Nx Cloud heartbeat process failed to report its status in time
|
||||
|
||||
While running in CI environments, Nx Cloud spawns a background process called the "heartbeat" to help maintain status synchronization between itself and external platforms. When the heartbeat process does not report to Nx Cloud for 30 seconds or longer, Nx Cloud assumes something has gone wrong and terminates the current CI Pipeline Execution.
|
||||
|
||||
This behavior can be disabled by setting the [--require-explicit-completion](https://nx.dev/ci/reference/nx-cloud-cli#requireexplicitcompletion) flag to `true` on your `nx-cloud start-ci-run` command.
|
||||
|
||||
### A command was issued to stop all Nx Cloud agents
|
||||
|
||||
Nx Cloud provides two commands to forcibly stop agents, [stop-all-agents and complete-ci-run](https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-stopallagents).
|
||||
|
||||
Once these commands are invoked, the current CI Pipeline Execution is closed and can no longer receive new work.
|
||||
|
||||
### Nx Cloud agents were stopped due to an error
|
||||
|
||||
Nx Cloud detected a failed task in the current CI Pipeline Execution and has halted further execution.
|
||||
|
||||
This behavior can be disabled by setting the [--stop-agents-on-failure](https://nx.dev/ci/reference/nx-cloud-cli#stopagentsonfailure) flag to `false` on your `nx-cloud start-ci-run` command.
|
||||
|
||||
## Nx Agents-Related
|
||||
|
||||
### Failed to start Nx Agents workflow
|
||||
|
||||
Nx Cloud was unable to start the agents workflow with the configuration provided to `nx-cloud start-ci-run`. View the CI Pipeline Execution in the Nx Cloud UI for additional details.
|
||||
|
||||
### Unable to get workflow status from Nx Agents
|
||||
|
||||
Nx Cloud was unable to communicate with the Nx Agents assigned to a workflow for the current CI Pipeline Execution. View the CI Pipeline Execution in the Nx Cloud UI for additional details.
|
||||
|
||||
## Status Reconciliation-Related
|
||||
|
||||
### One or more workflows were cancelled
|
||||
|
||||
The current CI Pipeline Execution had a workflow cancelled due to either:
|
||||
|
||||
- a manual request in the Nx Cloud UI, or
|
||||
- a push to the same branch that already had a running workflow.
|
||||
|
||||
### One or more workflows encountered a critical error
|
||||
|
||||
The current CI Pipeline Execution encountered a critical error in a child execution environment. View the CI Pipeline Execution in the Nx Cloud UI for additional details.
|
||||
|
||||
### One or more workflows failed
|
||||
|
||||
The current CI Pipeline Execution had at least one workflow with failed steps.
|
||||
|
||||
### One or more workflows encountered an error
|
||||
|
||||
The current CI Pipeline Execution had at least one workflow that executed tasks which failed. See also: [Nx Cloud agents were stopped due to an error](#nx-cloud-agents-were-stopped-due-to-an-error)
|
||||
|
||||
### One or more workflows timed out
|
||||
|
||||
The current CI Pipeline Execution had at least one workflow that exceeded the timeout duration. View the CI Pipeline Execution in the Nx Cloud UI for additional details.
|
||||
@@ -212,16 +212,16 @@ pnpm nx build landing-page
|
||||
Clearly this is not a scalable solution as it requires us to manually add every new app to the pipeline (and it doesn't include other tasks like `lint`, `test` etc). To improve this we can change the command to run the `build` for all projects like
|
||||
|
||||
```{% command="nx run-many -t build" %}
|
||||
✔ nx run shared-product-types:build (429ms)
|
||||
✔ nx run shared-product-ui:build (455ms)
|
||||
✔ nx run shared-header:build (467ms)
|
||||
✔ nx run landing-page:build:production (3s)
|
||||
✔ nx run admin:build:production (3s)
|
||||
✔ nx run cart:build:production (3s)
|
||||
✔ nx run shared-product-types:build (429ms)
|
||||
✔ nx run shared-product-ui:build (455ms)
|
||||
✔ nx run shared-header:build (467ms)
|
||||
✔ nx run landing-page:build:production (3s)
|
||||
✔ nx run admin:build:production (3s)
|
||||
✔ nx run cart:build:production (3s)
|
||||
|
||||
————————————————————————————————————————————————————————————————
|
||||
————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 6 projects (10s)
|
||||
NX Successfully ran target build for 6 projects (10s)
|
||||
```
|
||||
|
||||
This change makes our CI pipeline configuration more maintainable. For a small repository, this might be good enough, but after a little bit of growth this approach will cause your CI times to become unmanageable.
|
||||
@@ -229,14 +229,14 @@ This change makes our CI pipeline configuration more maintainable. For a small r
|
||||
Nx comes with a dedicated ["affected" command](/ci/features/affected) to help with that by only running tasks for projects that were affected by the changes in a given PR.
|
||||
|
||||
```{% command="nx affected -t build" %}
|
||||
✔ nx run shared-product-types:build (404ms)
|
||||
✔ nx run shared-product-ui:build (445ms)
|
||||
✔ nx run shared-header:build (465ms)
|
||||
✔ nx run cart:build:production (3s)
|
||||
✔ nx run shared-product-types:build (404ms)
|
||||
✔ nx run shared-product-ui:build (445ms)
|
||||
✔ nx run shared-header:build (465ms)
|
||||
✔ nx run cart:build:production (3s)
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project cart and 3 tasks it depends on (4s)
|
||||
NX Successfully ran target build for project cart and 3 tasks it depends on (4s)
|
||||
```
|
||||
|
||||
### Configuring the Comparison Range for Affected Commands
|
||||
@@ -336,8 +336,14 @@ This wires up all the CI for you and configures access. Folks who can see your r
|
||||
|
||||
To manually connect your workspace to Nx Cloud, run the following command in your repository:
|
||||
|
||||
```shell
|
||||
pnpm nx connect
|
||||
```{% command="pnpm nx connect" %}
|
||||
$ nx g nx:connect-to-nx-cloud --quiet --no-interactive
|
||||
|
||||
NX Your Nx Cloud workspace is public
|
||||
|
||||
To restrict access, connect it to your Nx Cloud account:
|
||||
- Push your changes
|
||||
- Login at https://cloud.nx.app to connect your repository
|
||||
```
|
||||
|
||||
Click the link in the terminal to claim your workspace on [nx.app](https://nx.app).
|
||||
@@ -360,18 +366,18 @@ What is more, if you run tasks locally, you will also get cache hits:
|
||||
|
||||
```{% command="nx run-many -t build" %}
|
||||
...
|
||||
✔ nx run express-legacy:build [remote cache]
|
||||
✔ nx run nx-plugin-legacy:build [remote cache]
|
||||
✔ nx run esbuild-legacy:build [remote cache]
|
||||
✔ nx run react-native-legacy:build [remote cache]
|
||||
✔ nx run angular-legacy:build [remote cache]
|
||||
✔ nx run remix-legacy:build [remote cache]
|
||||
✔ nx run express-legacy:build [remote cache]
|
||||
✔ nx run nx-plugin-legacy:build [remote cache]
|
||||
✔ nx run esbuild-legacy:build [remote cache]
|
||||
✔ nx run react-native-legacy:build [remote cache]
|
||||
✔ nx run angular-legacy:build [remote cache]
|
||||
✔ nx run remix-legacy:build [remote cache]
|
||||
|
||||
————————————————————————————————————————————————
|
||||
————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 58 projects and 62 tasks they depend on (1m)
|
||||
NX Successfully ran target build for 58 projects and 62 tasks they depend on (1m)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 116 out of 120 tasks.
|
||||
Nx read the output from the cache instead of running the command for 116 out of 120 tasks.
|
||||
```
|
||||
|
||||
You might also want to learn more about [how to fine-tune caching](/recipes/running-tasks/configure-inputs) to get even better results.
|
||||
|
||||
@@ -207,16 +207,16 @@ pnpm nx build landing-page
|
||||
Clearly this is not a scalable solution as it requires us to manually add every new app to the pipeline (and it doesn't include other tasks like `lint`, `test` etc). To improve this we can change the command to run the `build` for all projects like
|
||||
|
||||
```{% command="nx run-many -t build" %}
|
||||
✔ nx run shared-product-types:build (429ms)
|
||||
✔ nx run shared-product-ui:build (455ms)
|
||||
✔ nx run shared-header:build (467ms)
|
||||
✔ nx run landing-page:build:production (3s)
|
||||
✔ nx run admin:build:production (3s)
|
||||
✔ nx run cart:build:production (3s)
|
||||
✔ nx run shared-product-types:build (429ms)
|
||||
✔ nx run shared-product-ui:build (455ms)
|
||||
✔ nx run shared-header:build (467ms)
|
||||
✔ nx run landing-page:build:production (3s)
|
||||
✔ nx run admin:build:production (3s)
|
||||
✔ nx run cart:build:production (3s)
|
||||
|
||||
————————————————————————————————————————————————————————————————
|
||||
————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 6 projects (10s)
|
||||
NX Successfully ran target build for 6 projects (10s)
|
||||
```
|
||||
|
||||
This change makes our CI pipeline configuration more maintainable. For a small repository, this might be good enough, but after a little bit of growth this approach will cause your CI times to become unmanageable.
|
||||
@@ -224,14 +224,14 @@ This change makes our CI pipeline configuration more maintainable. For a small r
|
||||
Nx comes with a dedicated ["affected" command](/ci/features/affected) to help with that by only running tasks for projects that were affected by the changes in a given PR.
|
||||
|
||||
```{% command="nx affected -t build" %}
|
||||
✔ nx run shared-product-types:build (404ms)
|
||||
✔ nx run shared-product-ui:build (445ms)
|
||||
✔ nx run shared-header:build (465ms)
|
||||
✔ nx run cart:build:production (3s)
|
||||
✔ nx run shared-product-types:build (404ms)
|
||||
✔ nx run shared-product-ui:build (445ms)
|
||||
✔ nx run shared-header:build (465ms)
|
||||
✔ nx run cart:build:production (3s)
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project cart and 3 tasks it depends on (4s)
|
||||
NX Successfully ran target build for project cart and 3 tasks it depends on (4s)
|
||||
```
|
||||
|
||||
### Configuring the Comparison Range for Affected Commands
|
||||
@@ -345,18 +345,18 @@ What is more, if you run tasks locally, you will also get cache hits:
|
||||
|
||||
```{% command="nx run-many -t build" %}
|
||||
...
|
||||
✔ nx run express-legacy:build [remote cache]
|
||||
✔ nx run nx-plugin-legacy:build [remote cache]
|
||||
✔ nx run esbuild-legacy:build [remote cache]
|
||||
✔ nx run react-native-legacy:build [remote cache]
|
||||
✔ nx run angular-legacy:build [remote cache]
|
||||
✔ nx run remix-legacy:build [remote cache]
|
||||
✔ nx run express-legacy:build [remote cache]
|
||||
✔ nx run nx-plugin-legacy:build [remote cache]
|
||||
✔ nx run esbuild-legacy:build [remote cache]
|
||||
✔ nx run react-native-legacy:build [remote cache]
|
||||
✔ nx run angular-legacy:build [remote cache]
|
||||
✔ nx run remix-legacy:build [remote cache]
|
||||
|
||||
————————————————————————————————————————————————
|
||||
————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 58 projects and 62 tasks they depend on (1m)
|
||||
NX Successfully ran target build for 58 projects and 62 tasks they depend on (1m)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 116 out of 120 tasks.
|
||||
Nx read the output from the cache instead of running the command for 116 out of 120 tasks.
|
||||
```
|
||||
|
||||
You might also want to learn more about [how to fine-tune caching](/recipes/running-tasks/configure-inputs) to get even better results.
|
||||
|
||||
@@ -470,14 +470,14 @@ More conveniently, we can also run them in parallel using the following syntax:
|
||||
|
||||
```{% command="nx run-many -t test lint e2e" path="myngapp" %}
|
||||
|
||||
✔ nx run e2e:lint (1s)
|
||||
✔ nx run myngapp:lint (1s)
|
||||
✔ nx run myngapp:test (2s)
|
||||
✔ nx run e2e:e2e (6s)
|
||||
✔ nx run e2e:lint (1s)
|
||||
✔ nx run myngapp:lint (1s)
|
||||
✔ nx run myngapp:test (2s)
|
||||
✔ nx run e2e:e2e (6s)
|
||||
|
||||
——————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran targets test, lint, e2e for 2 projects (8s)
|
||||
NX Successfully ran targets test, lint, e2e for 2 projects (8s)
|
||||
```
|
||||
|
||||
### Caching
|
||||
@@ -490,16 +490,16 @@ Note that all of these targets are automatically cached by Nx. If you re-run a s
|
||||
|
||||
```{% command="nx run-many -t test lint e2e" path="myngapp" %}
|
||||
|
||||
✔ nx run myngapp:lint [existing outputs match the cache, left as is]
|
||||
✔ nx run e2e:lint [existing outputs match the cache, left as is]
|
||||
✔ nx run myngapp:test [existing outputs match the cache, left as is]
|
||||
✔ nx run e2e:e2e [existing outputs match the cache, left as is]
|
||||
✔ nx run myngapp:lint [existing outputs match the cache, left as is]
|
||||
✔ nx run e2e:lint [existing outputs match the cache, left as is]
|
||||
✔ nx run myngapp:test [existing outputs match the cache, left as is]
|
||||
✔ nx run e2e:e2e [existing outputs match the cache, left as is]
|
||||
|
||||
———————————————————————————————————————————————————————
|
||||
———————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran targets test, lint, e2e for 2 projects (143ms)
|
||||
Successfully ran targets test, lint, e2e for 2 projects (143ms)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 4 out of 4 tasks.
|
||||
Nx read the output from the cache instead of running the command for 4 out of 4 tasks.
|
||||
```
|
||||
|
||||
Not all tasks might be cacheable though. You can configure the `cache` properties in the targets under `targetDefaults` in the `nx.json` file. You can also [learn more about how caching works](/features/cache-task-results).
|
||||
@@ -514,44 +514,44 @@ Generators allow you to easily scaffold code, configuration or entire projects.
|
||||
|
||||
```{% command="npx nx list @nx/angular" path="myngapp" %}
|
||||
|
||||
> NX Capabilities in @nx/angular:
|
||||
NX Capabilities in @nx/angular:
|
||||
|
||||
> NX Capabilities in @nx/angular:
|
||||
NX Capabilities in @nx/angular:
|
||||
|
||||
GENERATORS
|
||||
GENERATORS
|
||||
|
||||
add-linting : Adds linting configuration to an Angular project.
|
||||
application : Creates an Angular application.
|
||||
component : Generate an Angular Component.
|
||||
...
|
||||
library : Creates an Angular library.
|
||||
library-secondary-entry-point : Creates a secondary entry point for an Angular publishable library.
|
||||
remote : Generate a Remote Angular Module Federation Application.
|
||||
move : Moves an Angular application or library to another folder within the workspace and updates the project configuration.
|
||||
convert-to-with-mf : Converts an old micro frontend configuration...
|
||||
host : Generate a Host Angular Module Federation Application.
|
||||
ng-add : Migrates an Angular CLI workspace to Nx or adds the Angular plugin to an Nx workspace.
|
||||
ngrx : Adds NgRx support to an application or library.
|
||||
scam-to-standalone : Convert an existing Single Component Angular Module (SCAM) to a Standalone Component.
|
||||
scam : Generate a component with an accompanying Single Component Angular Module (SCAM).
|
||||
scam-directive : Generate a directive with an accompanying Single Component Angular Module (SCAM).
|
||||
scam-pipe : Generate a pipe with an accompanying Single Component Angular Module (SCAM).
|
||||
setup-mf : Generate a Module Federation configuration for a given Angular application.
|
||||
setup-ssr : Generate Angular Universal (SSR) setup for an Angular application.
|
||||
setup-tailwind : Configures Tailwind CSS for an application or a buildable/publishable library.
|
||||
stories : Creates stories/specs for all components declared in a project.
|
||||
storybook-configuration : Adds Storybook configuration to a project.
|
||||
cypress-component-configuration : Setup Cypress component testing for a project.
|
||||
web-worker : Creates a Web Worker.
|
||||
directive : Generate an Angular directive.
|
||||
ngrx-feature-store : Adds an NgRx Feature Store to an application or library.
|
||||
ngrx-root-store : Adds an NgRx Root Store to an application.
|
||||
pipe : Generate an Angular Pipe
|
||||
add-linting : Adds linting configuration to an Angular project.
|
||||
application : Creates an Angular application.
|
||||
component : Generate an Angular Component.
|
||||
...
|
||||
library : Creates an Angular library.
|
||||
library-secondary-entry-point : Creates a secondary entry point for an Angular publishable library.
|
||||
remote : Generate a Remote Angular Module Federation Application.
|
||||
move : Moves an Angular application or library to another folder within the workspace and updates the project configuration.
|
||||
convert-to-with-mf : Converts an old micro frontend configuration...
|
||||
host : Generate a Host Angular Module Federation Application.
|
||||
ng-add : Migrates an Angular CLI workspace to Nx or adds the Angular plugin to an Nx workspace.
|
||||
ngrx : Adds NgRx support to an application or library.
|
||||
scam-to-standalone : Convert an existing Single Component Angular Module (SCAM) to a Standalone Component.
|
||||
scam : Generate a component with an accompanying Single Component Angular Module (SCAM).
|
||||
scam-directive : Generate a directive with an accompanying Single Component Angular Module (SCAM).
|
||||
scam-pipe : Generate a pipe with an accompanying Single Component Angular Module (SCAM).
|
||||
setup-mf : Generate a Module Federation configuration for a given Angular application.
|
||||
setup-ssr : Generate Angular Universal (SSR) setup for an Angular application.
|
||||
setup-tailwind : Configures Tailwind CSS for an application or a buildable/publishable library.
|
||||
stories : Creates stories/specs for all components declared in a project.
|
||||
storybook-configuration : Adds Storybook configuration to a project.
|
||||
cypress-component-configuration : Setup Cypress component testing for a project.
|
||||
web-worker : Creates a Web Worker.
|
||||
directive : Generate an Angular directive.
|
||||
ngrx-feature-store : Adds an NgRx Feature Store to an application or library.
|
||||
ngrx-root-store : Adds an NgRx Root Store to an application.
|
||||
pipe : Generate an Angular Pipe
|
||||
|
||||
EXECUTORS/BUILDERS/
|
||||
EXECUTORS/BUILDERS/
|
||||
|
||||
delegate-build : Delegates the build to a different target while supporting incremental builds.
|
||||
...
|
||||
delegate-build : Delegates the build to a different target while supporting incremental builds.
|
||||
...
|
||||
```
|
||||
|
||||
{% callout type="info" title="Prefer a more visual UI?" %}
|
||||
@@ -565,7 +565,7 @@ More info can be found in [the integrate with editors article](/features/integra
|
||||
Run the following command to generate a new "hello-world" component. Note how we append `--dry-run` to first check the output.
|
||||
|
||||
```{% command="npx nx g @nx/angular:component hello-world --directory=src/app/hello-world --standalone --dry-run" path="myngapp" %}
|
||||
> NX Generating @nx/angular:component
|
||||
NX Generating @nx/angular:component
|
||||
|
||||
CREATE src/app/hello-world/hello-world.component.css
|
||||
CREATE src/app/hello-world/hello-world.component.html
|
||||
@@ -614,9 +614,9 @@ styles.ef46db3751d8e999.css | styles | 0 bytes |
|
||||
|
||||
Build at: 2023-05-23T14:00:31.981Z - Hash: 9086e92ce0bfefca - Time: 5228ms
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project myngapp (7s)
|
||||
Successfully ran target build for project myngapp (7s)
|
||||
```
|
||||
|
||||
All the required files will be placed in the `dist/myngapp` folder and can be deployed to your favorite hosting provider.
|
||||
@@ -1051,29 +1051,29 @@ export class ProductsComponent {}
|
||||
If you lint your workspace you'll get an error now:
|
||||
|
||||
```{% command="nx run-many -t lint" %}
|
||||
✖ nx run products:lint
|
||||
Linting "products"...
|
||||
✖ nx run products:lint
|
||||
Linting "products"...
|
||||
|
||||
/Users/juri/nrwl/content/myngapp/modules/products/src/lib/products/products.component.ts
|
||||
3:1 error A project tagged with "scope:products" can only depend on libs tagged with "scope:products", "scope:shared" @nx/enforce-module-boundaries
|
||||
/Users/juri/nrwl/content/myngapp/modules/products/src/lib/products/products.component.ts
|
||||
3:1 error A project tagged with "scope:products" can only depend on libs tagged with "scope:products", "scope:shared" @nx/enforce-module-boundaries
|
||||
|
||||
✖ 1 problem (1 error, 0 warnings)
|
||||
✖ 1 problem (1 error, 0 warnings)
|
||||
|
||||
Lint errors found in the listed files.
|
||||
Lint errors found in the listed files.
|
||||
|
||||
✔ nx run orders:lint (1s)
|
||||
✔ nx run myngapp:lint (1s)
|
||||
✔ nx run e2e:lint (682ms)
|
||||
✔ nx run shared-ui:lint (797ms)
|
||||
✔ nx run orders:lint (1s)
|
||||
✔ nx run myngapp:lint (1s)
|
||||
✔ nx run e2e:lint (682ms)
|
||||
✔ nx run shared-ui:lint (797ms)
|
||||
|
||||
—————————————————————————————————————————————————————————————————————
|
||||
—————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Ran target lint for 5 projects (2s)
|
||||
NX Ran target lint for 5 projects (2s)
|
||||
|
||||
✔ 4/5 succeeded [0 read from cache]
|
||||
✔ 4/5 succeeded [0 read from cache]
|
||||
|
||||
✖ 1/5 targets failed, including the following:
|
||||
- nx run products:lint
|
||||
✖ 1/5 targets failed, including the following:
|
||||
- nx run products:lint
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ title="Tutorial: Standalone Angular Application"
|
||||
Create a new Angular monorepo with the following command:
|
||||
|
||||
```{% command="npx create-nx-workspace@latest angular-monorepo --preset=angular-monorepo" path="~" %}
|
||||
> NX Let's create a new workspace [https://nx.dev/getting-started/intro]
|
||||
NX Let's create a new workspace [https://nx.dev/getting-started/intro]
|
||||
|
||||
✔ Application name · angular-store
|
||||
✔ Which bundler would you like to use? · esbuild
|
||||
@@ -566,7 +566,7 @@ Nx plugins usually provide [generators](/features/generate-code) that allow you
|
||||
|
||||
```{% command="npx nx list @nx/angular" path="angular-monorepo" %}
|
||||
|
||||
> NX Capabilities in @nx/angular:
|
||||
NX Capabilities in @nx/angular:
|
||||
|
||||
GENERATORS
|
||||
|
||||
@@ -608,7 +608,7 @@ More info can be found in [the integrate with editors article](/features/integra
|
||||
Run the following command to generate a new `inventory` application. Note how we append `--dry-run` to first check the output.
|
||||
|
||||
```{% command="npx nx g @nx/angular:app inventory --directory=apps/inventory --dry-run" path="angular-monorepo" %}
|
||||
> NX Generating @nx/angular:application
|
||||
NX Generating @nx/angular:application
|
||||
|
||||
✔ Would you like to configure routing for this application? (y/N) · false
|
||||
✔ Would you like to use Standalone Components? (y/N) · true
|
||||
@@ -1009,17 +1009,16 @@ One thing to highlight is that Nx is able to [cache the tasks you run](/features
|
||||
Note that all of these targets are automatically cached by Nx. If you re-run a single one or all of them again, you'll see that the task completes immediately. In addition, (as can be seen in the output example below) there will be a note that a matching cache result was found and therefore the task was not run again.
|
||||
|
||||
```{% command="nx run-many -t test lint e2e" path="angular-monorepo" %}
|
||||
✔ nx run e2e:lint [existing outputs match the cache, left as is]
|
||||
✔ nx run angular-store:lint [existing outputs match the cache, left as is]
|
||||
✔ nx run angular-store:test [existing outputs match the cache, left as is]
|
||||
✔ nx run e2e:e2e [existing outputs match the cache, left as is]
|
||||
|
||||
✔ nx run e2e:lint [existing outputs match the cache, left as is]
|
||||
✔ nx run angular-store:lint [existing outputs match the cache, left as is]
|
||||
✔ nx run angular-store:test [existing outputs match the cache, left as is]
|
||||
✔ nx run e2e:e2e [existing outputs match the cache, left as is]
|
||||
——————————————————————————————————————————————————————
|
||||
|
||||
——————————————————————————————————————————————————————
|
||||
NX Successfully ran targets test, lint, e2e for 5 projects (54ms)
|
||||
|
||||
> NX Successfully ran targets test, lint, e2e for 5 projects (54ms)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 10 out of 10 tasks.
|
||||
Nx read the output from the cache instead of running the command for 10 out of 10 tasks.
|
||||
```
|
||||
|
||||
Not all tasks might be cacheable though. You can configure `cacheableOperations` in the `nx.json` file. You can also [learn more about how caching works](/features/cache-task-results).
|
||||
@@ -1153,7 +1152,7 @@ nx graph --affected
|
||||
If you're ready and want to ship your applications, you can build them using
|
||||
|
||||
```{% command="npx nx run-many -t build" path="angular-monorepo" %}
|
||||
> NX Generating @nx/angular:component
|
||||
NX Generating @nx/angular:component
|
||||
|
||||
CREATE libs/orders/src/lib/order-list/order-list.component.css
|
||||
CREATE libs/orders/src/lib/order-list/order-list.component.html
|
||||
@@ -1162,12 +1161,12 @@ CREATE libs/orders/src/lib/order-list/order-list.component.ts
|
||||
UPDATE libs/orders/src/index.ts
|
||||
❯ nx run-many -t build
|
||||
|
||||
✔ nx run inventory:build:production (7s)
|
||||
✔ nx run angular-store:build:production (7s)
|
||||
✔ nx run inventory:build:production (7s)
|
||||
✔ nx run angular-store:build:production (7s)
|
||||
|
||||
———————————————————————————————————————————————————————————————————————
|
||||
———————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 2 projects (7s)
|
||||
NX Successfully ran target build for 2 projects (7s)
|
||||
```
|
||||
|
||||
All the required files will be placed in `dist/apps/angular-store` and `dist/apps/inventory` and can be deployed to your favorite hosting provider.
|
||||
@@ -1321,36 +1320,36 @@ export class ProductListComponent {}
|
||||
If you lint your workspace you'll get an error now:
|
||||
|
||||
```{% command="nx run-many -t lint" %}
|
||||
> NX Running target lint for 7 projects
|
||||
✖ nx run products:lint
|
||||
Linting "products"...
|
||||
NX Running target lint for 7 projects
|
||||
✖ nx run products:lint
|
||||
Linting "products"...
|
||||
|
||||
/Users/isaac/Documents/code/nx-recipes/angular-monorepo/libs/products/src/lib/product-list/product-list.component.ts
|
||||
5:1 error A project tagged with "scope:products" can only depend on libs tagged with "scope:products", "scope:shared" @nx/enforce-module-boundaries
|
||||
5:10 warning 'OrderListComponent' is defined but never used @typescript-eslint/no-unused-vars
|
||||
/Users/isaac/Documents/code/nx-recipes/angular-monorepo/libs/products/src/lib/product-list/product-list.component.ts
|
||||
5:1 error A project tagged with "scope:products" can only depend on libs tagged with "scope:products", "scope:shared" @nx/enforce-module-boundaries
|
||||
5:10 warning 'OrderListComponent' is defined but never used @typescript-eslint/no-unused-vars
|
||||
|
||||
✖ 2 problems (1 error, 1 warning)
|
||||
✖ 2 problems (1 error, 1 warning)
|
||||
|
||||
Lint warnings found in the listed files.
|
||||
Lint warnings found in the listed files.
|
||||
|
||||
Lint errors found in the listed files.
|
||||
Lint errors found in the listed files.
|
||||
|
||||
|
||||
✔ nx run orders:lint (1s)
|
||||
✔ nx run angular-store:lint (1s)
|
||||
✔ nx run angular-store-e2e:lint (689ms)
|
||||
✔ nx run inventory-e2e:lint (690ms)
|
||||
✔ nx run inventory:lint (858ms)
|
||||
✔ nx run shared-ui:lint (769ms)
|
||||
✔ nx run orders:lint (1s)
|
||||
✔ nx run angular-store:lint (1s)
|
||||
✔ nx run angular-store-e2e:lint (689ms)
|
||||
✔ nx run inventory-e2e:lint (690ms)
|
||||
✔ nx run inventory:lint (858ms)
|
||||
✔ nx run shared-ui:lint (769ms)
|
||||
|
||||
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Ran target lint for 7 projects (3s)
|
||||
NX Ran target lint for 7 projects (3s)
|
||||
|
||||
✔ 6/7 succeeded [0 read from cache]
|
||||
✔ 6/7 succeeded [0 read from cache]
|
||||
|
||||
✖ 1/7 targets failed, including the following:
|
||||
- nx run products:lint
|
||||
✖ 1/7 targets failed, including the following:
|
||||
- nx run products:lint
|
||||
```
|
||||
|
||||
If you have the ESLint plugin installed in your IDE you should immediately see an error:
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
# Inferred Tasks
|
||||
# Inferred Tasks (Project Crystal)
|
||||
|
||||
In Nx version 18, many Nx plugins will automatically infer tasks for your projects based on the configuration of different tools. Many tools have configuration files which determine what a tool does. Nx is able to cache the results of running the tool. Nx plugins use the same configuration files to infer how Nx should [run the task](/features/run-tasks). This includes [fine-tuned cache settings](/features/cache-task-results) and automatic [task dependencies](/concepts/task-pipeline-configuration).
|
||||
|
||||
For example, the `@nx/webpack` plugin infers tasks to run webpack through Nx based on your repository's webpack configuration. This configuration already defines the destination of your build files, so Nx reads that value and caches the correct output files.
|
||||
|
||||
{% youtube
|
||||
src="https://youtu.be/wADNsVItnsM"
|
||||
title="Project Crystal"
|
||||
/%}
|
||||
|
||||
## How Does a Plugin Infer Tasks?
|
||||
|
||||
Every plugin has its own custom logic, but in order to infer tasks, they all go through the following steps.
|
||||
|
||||
@@ -135,11 +135,11 @@ Hello, World!
|
||||
||----w |
|
||||
|| ||
|
||||
|
||||
—————————————————————————————————————————————————————————————————————————————————————————
|
||||
—————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target serve for project cli (2s)
|
||||
NX Successfully ran target serve for project cli (2s)
|
||||
|
||||
See Nx Cloud run details at https://nx.app/runs/THRW7SDRL9S
|
||||
See Nx Cloud run details at https://nx.app/runs/THRW7SDRL9S
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ Update `packages/ascii/assets/cow.txt`:
|
||||
|
||||
```plaintext
|
||||
_____
|
||||
< Hi! >
|
||||
< moo >
|
||||
-----
|
||||
\ ^__^
|
||||
\ (oo)\_______
|
||||
@@ -66,14 +66,14 @@ Printing the affected projects can be handy, but usually you want to do somethin
|
||||
**Run `nx affected -t build` to rebuild only the projects affected by the change.**
|
||||
|
||||
```shell
|
||||
✔ nx run blog:build (1s)
|
||||
✔ nx run cli:build (2s)
|
||||
✔ nx run blog:build (1s)
|
||||
✔ nx run cli:build (2s)
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 2 projects (2s)
|
||||
NX Successfully ran target build for 2 projects (2s)
|
||||
|
||||
See Nx Cloud run details at https://nx.app/runs/XfhRFaOyGCE
|
||||
See Nx Cloud run details at https://nx.app/runs/XfhRFaOyGCE
|
||||
```
|
||||
|
||||
Note that Nx only built `blog` and `cli`. It didn't build `ascii` because there is no build script created for it.
|
||||
|
||||
@@ -99,14 +99,13 @@ ______________________________________________________
|
||||
(__)\ )\/\
|
||||
||----w |
|
||||
|| ||
|
||||
Done in 0.14s.
|
||||
Done in 0.14s.
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target serve for project cow
|
||||
NX Successfully ran target serve for project cow
|
||||
|
||||
|
||||
See Nx Cloud run details at https://nx.app/runs/nZBYYBEuIfG
|
||||
See Nx Cloud run details at https://nx.app/runs/nZBYYBEuIfG
|
||||
```
|
||||
|
||||
## View the Project Graph
|
||||
|
||||
@@ -24,7 +24,7 @@ To mitigate the impact of this change of direction, Nx will prompt you when runn
|
||||
```{% command="nx g lib my-lib --directory=shared/my-lib" path="~/myorg" %}
|
||||
✔ Which generator would you like to use? · @nx/node:library
|
||||
|
||||
> NX Generating @nx/node:library
|
||||
NX Generating @nx/node:library
|
||||
|
||||
? What should be the project name and where should it be generated? …
|
||||
❯ As provided:
|
||||
|
||||
+7
-38
@@ -1,49 +1,18 @@
|
||||
---
|
||||
title: Angular - The browserTarget
|
||||
description: This document explains the role of the browserTarget in Angular projects with a Storybook configuration, and how the Storybook executors use it.
|
||||
title: Angular - The projectBuildConfig
|
||||
description: This document explains the role of projectBuildConfig in Angular projects with a Storybook configuration, and how the Storybook executors use it.
|
||||
---
|
||||
|
||||
# The `browserTarget` for Angular projects with a Storybook configuration
|
||||
# Setting up `projectBuildConfig` for Nx versions `<14.1.8`
|
||||
|
||||
{% callout type="warning" title="Deprecated!" %}
|
||||
**Careful**: This is for older versions of Nx - for the latest version please look at the [Set up Storybook for Angular Projects](/recipes/storybook/overview-angular) recipe.
|
||||
{% /callout %}
|
||||
|
||||
{% callout type="note" title="Note" %}
|
||||
This documentation page contains information about the [Storybook plugin](/nx-api/storybook), specifically regarding [Angular projects that are using Storybook](/recipes/storybook/overview-angular).
|
||||
{% /callout %}
|
||||
|
||||
## Setting up `browserTarget`
|
||||
|
||||
If you're using [Storybook](/nx-api/storybook) in your Angular project, you will notice that `browserTarget` is specified for the `storybook` and `build-storybook` targets, much like it is done for `serve` or other targets. Angular needs the `browserTarget` for Storybook in order to know which configuration to use for the build. If your project is buildable (it has a `build` target, and uses the main Angular builder - `@angular-devkit/build-angular:browser`) the `browserTarget` for Storybook will use the `build` target, if it's not buildable it will use the `build-storybook` target.
|
||||
You do not have to do anything manually. Nx will create the configuration for you. Even if you are migrating from an older version of Nx, Nx will make sure to change your `package.json` Storybook targets to match the new schema.
|
||||
|
||||
You can read more about the `browserTarget` in the [official Angular documentation](https://angular.io/cli/serve).
|
||||
|
||||
Your Storybook targets in your `project.json` will look like this:
|
||||
|
||||
```jsonc {% fileName="project.json" %}
|
||||
"storybook": {
|
||||
"executor": "@storybook/angular:start-storybook",
|
||||
"options": {
|
||||
...
|
||||
"browserTarget": "my-project:build"
|
||||
},
|
||||
...
|
||||
},
|
||||
"build-storybook": {
|
||||
"executor": "@storybook/angular:build-storybook",
|
||||
...
|
||||
"options": {
|
||||
...
|
||||
"browserTarget": "my-project:build"
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
This setup instructs Nx to use the configuration under the `build` target of `my-project` when using the `storybook` and `build-storybook` executors.
|
||||
|
||||
## Setting up `projectBuildConfig` for Nx versions `<14.1.8`
|
||||
|
||||
**_Careful: This is for older versions of Nx - for the latest version please look at the section above, about `browserTarget`_**
|
||||
|
||||
If you are on Nx version `<14.1.8`, you're still using our custom executor, which means that you have to comply by the Nx Storybook schema. This means that the contents of `browserTarget` should be placed in the `projectBuildConfig` property. This is telling Storybook where to get the build configuration from. To know more about the purpose of `browserTarget` (and `projectBuildConfig`) read the section above.
|
||||
|
||||
If you're using Nx version `>=13.4.6` either in a new Nx workspace, or you migrated your older Nx workspace to Nx version `>=13.4.6`, Nx will automatically add the `projectBuildConfig` property in your projects `project.json` files, for projects that are using Storybook.
|
||||
@@ -15,7 +15,7 @@ Nx provides an `enforce-module-boundaries` eslint rule that enforces the public
|
||||
|
||||
To set up the lint rule, install these dependencies:
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/eslint-plugin @nx/devkit
|
||||
```
|
||||
|
||||
|
||||
@@ -25,22 +25,19 @@ To see the remote cache in action, run:
|
||||
src/index.tsx → dist...
|
||||
created dist in 786ms
|
||||
|
||||
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project header (2s)
|
||||
NX Successfully ran target build for project header (2s)
|
||||
|
||||
See logs and investigate cache misses at https://cloud.nx.app/runs/k0HDHACpL8
|
||||
See logs and investigate cache misses at https://cloud.nx.app/runs/k0HDHACpL8
|
||||
|
||||
NX Resetting the Nx workspace cache and stopping the Nx Daemon.
|
||||
|
||||
> NX Resetting the Nx workspace cache and stopping the Nx Daemon.
|
||||
This might take a few minutes.
|
||||
|
||||
This might take a few minutes.
|
||||
NX Daemon Server - Stopped
|
||||
|
||||
|
||||
> NX Daemon Server - Stopped
|
||||
|
||||
|
||||
> NX Successfully reset the Nx workspace.
|
||||
NX Successfully reset the Nx workspace.
|
||||
|
||||
|
||||
> nx run header:build [remote cache]
|
||||
@@ -53,13 +50,13 @@ created dist in 786ms
|
||||
src/index.tsx → dist...
|
||||
created dist in 786ms
|
||||
|
||||
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project header (664ms)
|
||||
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 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
|
||||
Nx Cloud made it possible to reuse header: https://nx.app/runs/P0X6ZGTkqZ
|
||||
```
|
||||
|
||||
## Skipping Cloud Cache
|
||||
|
||||
@@ -30,7 +30,7 @@ This will guide you through the setup, asking whether you want a monorepo or a s
|
||||
|
||||
```{% command="npx create-nx-workspace" path="~" %}
|
||||
|
||||
> NX Let's create a new workspace [https://nx.dev/getting-started/intro]
|
||||
NX Let's create a new workspace [https://nx.dev/getting-started/intro]
|
||||
|
||||
✔ Where would you like to create your workspace? · myorg
|
||||
? Which stack do you want to use? …
|
||||
|
||||
@@ -301,7 +301,7 @@ To use Module Federation well, we recommend that you enable [Nx Cloud](https://n
|
||||
when using `create-nx-workspace`, you can do the following.
|
||||
|
||||
```shell
|
||||
nx connect-to-nx-cloud
|
||||
nx connect
|
||||
```
|
||||
|
||||
With Nx Cloud enabled, a large set of builds can be skipped entirely when running the application locally (and in
|
||||
@@ -327,11 +327,11 @@ If you inspect the terminal output, you'll see something like this, even if you
|
||||
```shell
|
||||
> nx run about:build:development [existing outputs match the cache, left as is]
|
||||
|
||||
(snip)
|
||||
(snip)
|
||||
|
||||
> NX Successfully ran target build for project about
|
||||
NX Successfully ran target build for project about
|
||||
|
||||
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
|
||||
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ When using React Native in Nx, you get the out-of-the-box support for TypeScript
|
||||
|
||||
For existing Nx workspaces, install the `@nx/react-native` package to add React Native capabilities to it.
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/react-native
|
||||
```
|
||||
|
||||
|
||||
+22
-22
@@ -5,24 +5,24 @@ In this recipe, we'll show you how to create a [Remix](https://remix.run) applic
|
||||
## Create Nx Workspace
|
||||
|
||||
```{% command="npx create-nx-workspace acme --preset=apps" path="~/" %}
|
||||
> NX Let's create a new workspace [https://nx.dev/getting-started/intro]
|
||||
NX Let's create a new workspace [https://nx.dev/getting-started/intro]
|
||||
|
||||
✔ Do you want Nx Cloud to make your CI fast? · Yes
|
||||
|
||||
> NX Creating your v16.3.2 workspace.
|
||||
NX Creating your v16.3.2 workspace.
|
||||
|
||||
To make sure the command works reliably in all environments, and that the preset is applied correctly,
|
||||
Nx will run "npm install" several times. Please wait.
|
||||
To make sure the command works reliably in all environments, and that the preset is applied correctly,
|
||||
Nx will run "npm install" several times. Please wait.
|
||||
|
||||
✔ Installing dependencies with npm
|
||||
✔ Successfully created the workspace: acme.
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
|
||||
> NX First time using Nx? Check out this interactive Nx tutorial.
|
||||
NX First time using Nx? Check out this interactive Nx tutorial.
|
||||
|
||||
https://nx.dev/tutorials/package-based-repo-tutorial
|
||||
https://nx.dev/tutorials/package-based-repo-tutorial
|
||||
```
|
||||
|
||||
## Install Nx Remix Plugin
|
||||
@@ -31,7 +31,7 @@ In this recipe, we'll show you how to create a [Remix](https://remix.run) applic
|
||||
Make sure to install the `@nx/remix` version that is on the same minor version as the `nx` version in your repository. If the version numbers get out of sync, you can encounter some difficult to debug errors. You can [fix Nx version mismatches with this recipe](/recipes/tips-n-tricks/keep-nx-versions-in-sync).
|
||||
{% /callout %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/remix
|
||||
```
|
||||
|
||||
@@ -42,7 +42,7 @@ The command below uses the `as-provided` directory flag behavior, which is the d
|
||||
{% /callout %}
|
||||
|
||||
```{% command="nx g @nx/remix:app myapp --directory=apps/myapp" path="~/acme" %}
|
||||
> NX Generating @nx/remix:application
|
||||
NX Generating @nx/remix:application
|
||||
|
||||
✔ What unit test runner should be used? · vitest
|
||||
|
||||
@@ -88,9 +88,9 @@ Building Remix app in production mode...
|
||||
|
||||
Built in 857ms
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project myapp (3s)
|
||||
NX Successfully ran target build for project myapp (3s)
|
||||
```
|
||||
|
||||
2. To serve your application for use during development run:
|
||||
@@ -108,18 +108,18 @@ Remix App Server started at http://localhost:3000 (http://192.168.0.14:3000)
|
||||
```{% command="nx test myapp" path="~/acme" %}
|
||||
> nx run myapp:test
|
||||
|
||||
RUN v0.31.4 /Users/columferry/dev/nrwl/issues/remixguide/acme/apps/myapp
|
||||
RUN v0.31.4 /Users/columferry/dev/nrwl/issues/remixguide/acme/apps/myapp
|
||||
stderr | app/routes/index.spec.ts > test > should render
|
||||
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
|
||||
✓ app/routes/index.spec.ts (1 test) 10ms
|
||||
Test Files 1 passed (1)
|
||||
Tests 1 passed (1)
|
||||
Start at 16:15:45
|
||||
Duration 1.20s (transform 51ms, setup 139ms, collect 180ms, tests 10ms, environment 379ms, prepare 103ms)
|
||||
✓ app/routes/index.spec.ts (1 test) 10ms
|
||||
Test Files 1 passed (1)
|
||||
Tests 1 passed (1)
|
||||
Start at 16:15:45
|
||||
Duration 1.20s (transform 51ms, setup 139ms, collect 180ms, tests 10ms, environment 379ms, prepare 103ms)
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target test for project myapp (2s)
|
||||
NX Successfully ran target test for project myapp (2s)
|
||||
```
|
||||
|
||||
## Generating an Nx Library
|
||||
@@ -129,7 +129,7 @@ When developing your application, it often makes sense to split your codebase in
|
||||
To generate a library to use in your Remix application run:
|
||||
|
||||
```{% command="nx g @nx/remix:lib login --directory=libs/login" path="~/acme" %}
|
||||
> NX Generating @nx/remix:library
|
||||
NX Generating @nx/remix:library
|
||||
|
||||
✔ What test runner should be used? · vitest
|
||||
UPDATE nx.json
|
||||
@@ -176,7 +176,7 @@ You can also run test on your library:
|
||||
To generate a route for your application:
|
||||
|
||||
```{% command="nx g @nx/remix:route admin --path=apps/myapp/app/routes" path="~/acme" %}
|
||||
> NX Generating @nx/remix:route
|
||||
NX Generating @nx/remix:route
|
||||
|
||||
CREATE apps/myapp/app/routes/admin.tsx
|
||||
CREATE apps/myapp/app/styles/admin.css
|
||||
@@ -189,7 +189,7 @@ To use a Route Loader where the logic lives in your library, follow the steps be
|
||||
1. Generate a loader for your route:
|
||||
|
||||
```{% command="nx g @nx/remix:loader admin --path=apps/myapp/app/routes" path="~/acme" %}
|
||||
> NX Generating @nx/remix:loader
|
||||
NX Generating @nx/remix:loader
|
||||
|
||||
UPDATE apps/myapp/app/routes/admin.tsx
|
||||
```
|
||||
|
||||
@@ -41,7 +41,7 @@ At the next prompt, you can choose whether to use [Nx Cloud](https://nx.app) or
|
||||
|
||||
Your new workspace won’t have much in it because of the `apps` preset. You’ll need to generate an application to have some structure created. Add the Angular plugin to your workspace:
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/angular
|
||||
```
|
||||
|
||||
|
||||
@@ -24,10 +24,12 @@ jobs:
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
steps:
|
||||
- checkout: self
|
||||
fetchDepth: 0
|
||||
|
||||
# Set Azure Devops CLI default settings
|
||||
- bash: az devops configure --defaults organization=$(System.TeamFoundationCollectionUri) project=$(System.TeamProject)
|
||||
displayName: 'Set default Azure DevOps organization and project'
|
||||
|
||||
# Get last successfull commit from Azure Devops CLI
|
||||
- displayName: 'Get last successful commit SHA'
|
||||
condition: ne(variables['Build.Reason'], 'PullRequest')
|
||||
@@ -45,39 +47,19 @@ jobs:
|
||||
|
||||
# Required for nx affected if we're on a branch
|
||||
- script: git branch --track main origin/main
|
||||
- script: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution
|
||||
# This line enables distribution
|
||||
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
||||
- script: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
|
||||
- script: npm ci
|
||||
|
||||
- script: npx nx-cloud record -- nx format:check --base=$(BASE_SHA)
|
||||
- script: npx nx affected --base=$(BASE_SHA) -t lint test build --parallel=3
|
||||
- script: npx nx affected --base=$(BASE_SHA) -t lint test build e2e-ci
|
||||
```
|
||||
|
||||
{% callout type="note" title="Check your Shallow Fetch settings" %}
|
||||
|
||||
Nx needs additional Git history available for [`affected`](/ci/features/affected) to function correctly. Make sure
|
||||
Shallow fetching is disabled in your pipeline settings UI. For more info, check out this article from
|
||||
Microsoft [here](https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-checkout?view=azure-pipelines#shallow-fetch).
|
||||
|
||||
{% /callout %}
|
||||
|
||||
Unlike `GitHub Actions` and `CircleCI`, you don't have the metadata to help you track the last successful run on `main`.
|
||||
In the example below, the base is set to `HEAD~1` (for push) or branching point (for pull requests), but a more robust
|
||||
solution would be to tag a SHA in the main job once it succeeds and then use this tag as a base. You can also
|
||||
try [using the devops CLI within the pipeline yaml](#get-the-commit-of-the-last-successful-build). See
|
||||
the [nx-tag-successful-ci-run](https://github.com/nrwl/nx-tag-successful-ci-run)
|
||||
and [nx-set-shas](https://github.com/nrwl/nx-set-shas) (version 1 implements tagging mechanism) repositories for more
|
||||
information.
|
||||
|
||||
We also have to set `NX_BRANCH` explicitly. NX_BRANCH does not impact the functionality of your runs, but does provide a
|
||||
human-readable label to easily identify them in the Nx Cloud app.
|
||||
|
||||
The `main` job implements the CI workflow.
|
||||
|
||||
## Get the Commit of the Last Successful Build
|
||||
|
||||
In the example above we ran a script to retrieve the commit of the last successful build. The idea is to
|
||||
use [Azure Devops CLI](https://learn.microsoft.com/en-us/cli/azure/pipelines?view=azure-cli-latest)
|
||||
directly in
|
||||
the [Pipeline Yaml](https://learn.microsoft.com/en-us/azure/devops/cli/azure-devops-cli-in-yaml?view=azure-devops)
|
||||
In the example above, we ran a script to retrieve the commit of the last successful build. The idea is to
|
||||
use [Azure Devops CLI](https://learn.microsoft.com/en-us/cli/azure/pipelines?view=azure-cli-latest) directly in the [Pipeline Yaml](https://learn.microsoft.com/en-us/azure/devops/cli/azure-devops-cli-in-yaml?view=azure-devops)
|
||||
|
||||
First, we configure Devops CLI
|
||||
|
||||
@@ -100,17 +82,15 @@ Then we can query the pipelines API (providing the auth token)
|
||||
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
|
||||
```
|
||||
|
||||
We can target a specific build, in this example we specified:
|
||||
We can target a specific build; in this example, we specified:
|
||||
|
||||
- The branch (--branch)
|
||||
- The pipeline Id (--definition-ids)
|
||||
- The pipeline ID (--definition-ids)
|
||||
- The result type (--result)
|
||||
- The number of result (-top)
|
||||
- The number of the result (-top)
|
||||
|
||||
By default the command returns an entire JSON object with all the information. But we can narrow it down to the desired
|
||||
result with the `--query` param that uses [JMESPath](https://jmespath.org/)
|
||||
The command returns an entire JSON object with all the information. But we can narrow it down to the desired result with the `--query` param that uses [JMESPath](https://jmespath.org/)
|
||||
format ([more details](https://learn.microsoft.com/en-us/cli/azure/query-azure-cli?tabs=concepts%2Cbash))
|
||||
|
||||
Finally we extract the result in a
|
||||
common [custom variable](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=bash)
|
||||
named `BASE_SHA` used later by `nx affected` commands
|
||||
Finally, we extract the result in a common [custom variable](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=bash)
|
||||
named `BASE_SHA` used later by the `nx format` and `nx affected` commands.
|
||||
|
||||
@@ -1,33 +1,46 @@
|
||||
# Configuring CI Using Bitbucket Pipelines and Nx
|
||||
|
||||
Below is an example of an Bitbucket Pipelines, building and testing only what is affected.
|
||||
Below is an example of a Bitbucket Pipelines, building and testing only what is affected.
|
||||
|
||||
```yaml {% fileName="bitbucket-pipelines.yml" %}
|
||||
image: node:20
|
||||
|
||||
clone:
|
||||
depth: full
|
||||
|
||||
pipelines:
|
||||
pull-requests:
|
||||
'**':
|
||||
- step:
|
||||
name: 'Build and test affected apps on Pull Requests'
|
||||
caches: # optional
|
||||
- node
|
||||
script:
|
||||
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution
|
||||
# This line enables distribution
|
||||
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
||||
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
|
||||
- npm ci
|
||||
|
||||
- npx nx-cloud record -- nx format:check
|
||||
- npx nx affected -t lint test build --base=origin/master --head=HEAD
|
||||
- npx nx affected -t lint test build e2e-ci --base=origin/main
|
||||
|
||||
branches:
|
||||
main:
|
||||
- step:
|
||||
name: "Build and test affected apps on 'main' branch changes"
|
||||
caches: # optional
|
||||
- node
|
||||
script:
|
||||
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution
|
||||
- export NX_BRANCH=$BITBUCKET_PR_ID
|
||||
# This line enables distribution
|
||||
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
||||
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
|
||||
- npm ci
|
||||
|
||||
- npx nx-cloud record -- nx format:check
|
||||
- npx nx affected -t lint test build --base=HEAD~1
|
||||
- npx nx affected -t lint test build e2e-ci --base=HEAD~1
|
||||
```
|
||||
|
||||
The `pull-requests` and `main` jobs implement the CI workflow.
|
||||
|
||||
### Get the Commit of the Last Successful Build
|
||||
|
||||
Unlike `GitHub Actions` and `CircleCI`, you don't have the metadata to help you track the last successful run on `main`. In the example below, the base is set to `HEAD~1` (for push) or branching point (for pull requests), but a more robust solution would be to tag an SHA in the main job once it succeeds and then use this tag as a base. See the [nx-tag-successful-ci-run](https://github.com/nrwl/nx-tag-successful-ci-run) and [nx-set-shas](https://github.com/nrwl/nx-set-shas) (version 1 implements tagging mechanism) repositories for more information.
|
||||
|
||||
We also have to set `NX_BRANCH` explicitly.
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
# Configuring CI Using Circle CI and Nx
|
||||
|
||||
Below is an example of an Circle CI setup, building and testing only what is affected.
|
||||
Below is an example of a Circle CI setup, building, and testing only what is affected.
|
||||
|
||||
```yaml {% fileName=".circleci/config.yml" %}
|
||||
version: 2.1
|
||||
|
||||
orbs:
|
||||
nx: nrwl/nx@1.5.1
|
||||
nx: nrwl/nx@1.6.2
|
||||
|
||||
jobs:
|
||||
main:
|
||||
docker:
|
||||
- image: cimg/node:lts-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution
|
||||
# This line enables distribution
|
||||
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
||||
- run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
|
||||
- run: npm ci
|
||||
|
||||
- nx/set-shas
|
||||
|
||||
- run: npx nx-cloud record -- nx format:check
|
||||
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build --parallel=3
|
||||
- run: npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build e2e-ci
|
||||
workflows:
|
||||
build:
|
||||
jobs:
|
||||
@@ -26,13 +31,13 @@ workflows:
|
||||
|
||||
### Get the Commit of the Last Successful Build
|
||||
|
||||
`CircleCI` can track the last successful run on the `main` branch and use this as a reference point for the `BASE`. The `Nx Orb` provides a convenient implementation of this functionality which you can drop into your existing CI config. Specifically, `nx/set-shas` populates the `$NX_BASE` environment variable with the commit SHA of the last successful run.
|
||||
`CircleCI` can track the last successful run on the `main` branch and use this as a reference point for the `BASE`. The [Nx Orb](https://github.com/nrwl/nx-orb) provides a convenient implementation of this functionality, which you can drop into your existing CI workflow. Specifically, for push commits, `nx/set-shas` populates the `$NX_BASE` environment variable with the commit SHA of the last successful run.
|
||||
|
||||
To understand why knowing the last successful build is important for the affected command, check out the [in-depth explanation in Orb's docs](https://github.com/nrwl/nx-orb#background).
|
||||
|
||||
### Using CircleCI in a private repository
|
||||
|
||||
To use the [Nx Orb](https://github.com/nrwl/nx-orb) with a private repository on your main branch, you need to grant the orb access to your CircleCI API. You can do this by creating an environment variable called `CIRCLE_API_TOKEN` in the context or the project.
|
||||
To use the [Nx Orb](https://github.com/nrwl/nx-orb) with a private repository on your main branch, you need to grant the orb access to your CircleCI API. Create an environment variable called `CIRCLE_API_TOKEN` in the context of the project.
|
||||
|
||||
{% callout type="warning" title="Caution" %}
|
||||
It should be a user token, not the project token.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Configuring CI Using GitHub Actions and Nx
|
||||
|
||||
Below is an example of an GitHub Actions setup, building and testing only what is affected.
|
||||
Below is an example of a GitHub Actions setup, building, and testing only what is affected.
|
||||
|
||||
```yaml {% fileName=".github/workflows/ci.yml" %}
|
||||
name: CI
|
||||
@@ -23,22 +23,25 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# Cache node_modules
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
- run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution
|
||||
# This line enables distribution
|
||||
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
||||
- run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
|
||||
- run: npm ci
|
||||
|
||||
- uses: nrwl/nx-set-shas@v3
|
||||
# This line is needed for nx affected to work when CI is running on a PR
|
||||
- run: git branch --track main origin/main
|
||||
|
||||
- run: npx nx-cloud record -- nx format:check
|
||||
- run: npx nx affected -t lint test build --parallel=3
|
||||
- run: npx nx affected -t lint test build e2e-ci
|
||||
```
|
||||
|
||||
### Get the Commit of the Last Successful Build
|
||||
|
||||
`GitHub` can track the last successful run on the `main` branch and use this as a reference point for the `BASE`. The `nrwl/nx-set-shas` provides a convenient implementation of this functionality which you can drop into your existing CI config.
|
||||
The `GitHub` can track the last successful run on the `main` branch and use this as a reference point for the `BASE`. The [nrwl/nx-set-shas](https://github.com/marketplace/actions/nx-set-shas) provides a convenient implementation of this functionality, which you can drop into your existing CI workflow.
|
||||
|
||||
To understand why knowing the last successful build is important for the affected command, check out the [in-depth explanation in Actions's docs](https://github.com/marketplace/actions/nx-set-shas#background).
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
# Configuring CI Using GitLab and Nx
|
||||
|
||||
Below is an example of an GitLab setup, building and testing only what is affected.
|
||||
Below is an example of a GitLab setup, building and testing only what is affected.
|
||||
|
||||
```yaml {% fileName=".gitlab-ci.yml" %}
|
||||
image: node:18
|
||||
image: node:20
|
||||
|
||||
stages:
|
||||
- lint
|
||||
- test
|
||||
- build
|
||||
variables:
|
||||
GIT_DEPTH: 0
|
||||
|
||||
.distributed:
|
||||
main:
|
||||
interruptible: true
|
||||
only:
|
||||
- main
|
||||
@@ -21,36 +19,15 @@ stages:
|
||||
- package-lock.json
|
||||
paths:
|
||||
- .npm/
|
||||
before_script:
|
||||
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build" # this line enables distribution
|
||||
script:
|
||||
# Connect your workspace on <%= nxCloudHost %> and uncomment this to enable task distribution.
|
||||
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
||||
- npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
|
||||
|
||||
- npm ci --cache .npm --prefer-offline
|
||||
- NX_HEAD=$CI_COMMIT_SHA
|
||||
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
|
||||
|
||||
variables:
|
||||
GIT_DEPTH: 0
|
||||
|
||||
format-check:
|
||||
stage: test
|
||||
extends: .distributed
|
||||
script:
|
||||
- npx nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD
|
||||
|
||||
lint:
|
||||
stage: test
|
||||
extends: .distributed
|
||||
script:
|
||||
- npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint --parallel=3
|
||||
|
||||
test:
|
||||
stage: test
|
||||
extends: .distributed
|
||||
script:
|
||||
- npx nx affected --base=$NX_BASE --head=$NX_HEAD -t test --parallel=3
|
||||
|
||||
build:
|
||||
stage: build
|
||||
extends: .distributed
|
||||
script:
|
||||
- npx nx affected --base=$NX_BASE --head=$NX_HEAD -t build --parallel=3
|
||||
- npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint test build e2e-ci
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Configuring CI Using Jenkins and Nx
|
||||
|
||||
Below is an example of an Jenkins setup, building and testing only what is affected.
|
||||
Below is an example of a Jenkins setup, building and testing only what is affected.
|
||||
|
||||
```groovy
|
||||
pipeline {
|
||||
@@ -17,10 +17,12 @@ pipeline {
|
||||
}
|
||||
agent any
|
||||
steps {
|
||||
sh "npx nx-cloud start-ci-run --distribute-on='5 linux-medium-js' --stop-agents-after='build'" // this line enables distribution
|
||||
// This line enables distribution
|
||||
// The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
||||
sh "npx nx-cloud start-ci-run --distribute-on='5 linux-medium-js' --stop-agents-after='e2e-ci'"
|
||||
sh "npm ci"
|
||||
sh "npx nx-cloud record -- nx format:check"
|
||||
sh "npx nx affected --base=HEAD~1 -t lint test build --parallel=3"
|
||||
sh "npx nx affected --base=HEAD~1 -t lint test build e2e-ci"
|
||||
}
|
||||
}
|
||||
stage('PR') {
|
||||
@@ -29,10 +31,12 @@ pipeline {
|
||||
}
|
||||
agent any
|
||||
steps {
|
||||
sh "npx nx-cloud start-ci-run --distribute-on='5 linux-medium-js' --stop-agents-after='build'" // this line enables distribution
|
||||
// This line enables distribution
|
||||
// The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
|
||||
sh "npx nx-cloud start-ci-run --distribute-on='5 linux-medium-js' --stop-agents-after='e2e-ci'"
|
||||
sh "npm ci"
|
||||
sh "npx nx-cloud record -- nx format:check"
|
||||
sh "npx nx affected --base origin/${env.CHANGE_TARGET} -t lint test build --parallel=3"
|
||||
sh "npx nx affected --base origin/${env.CHANGE_TARGET} -t lint test build e2e-ci"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,9 +191,9 @@ Run the same command a second time and you'll see the build cache is being used:
|
||||
Compiling TypeScript files for project "is-even"...
|
||||
Done compiling TypeScript files for project "is-even".
|
||||
|
||||
—————————————————————————————————————————————————————————————————————
|
||||
—————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project is-even (713ms)
|
||||
NX Successfully ran target build for project is-even (713ms)
|
||||
```
|
||||
|
||||
## Running Multiple Tasks
|
||||
@@ -207,14 +207,14 @@ npx nx run-many -t build
|
||||
What you would get is the following:
|
||||
|
||||
```{% command="npx nx run-many -t build" %}
|
||||
✔ nx run is-even:build [existing outputs match the cache, left as is]
|
||||
✔ nx run is-odd:build (906ms)
|
||||
✔ nx run is-even:build [existing outputs match the cache, left as is]
|
||||
✔ nx run is-odd:build (906ms)
|
||||
|
||||
—————————————————————————————————————————————————————————————————
|
||||
—————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 2 projects (914ms)
|
||||
NX Successfully ran target build for 2 projects (914ms)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 1 out of 2 tasks.
|
||||
Nx read the output from the cache instead of running the command for 1 out of 2 tasks.
|
||||
```
|
||||
|
||||
Note how on the `is-even:build` it didn't run the build but rather pulled it out of the cache because the build has ran before. If you re-run the `run-many` command all of the builds would be cached.
|
||||
|
||||
@@ -221,11 +221,11 @@ Run the command:
|
||||
> tsc index.ts --outDir dist
|
||||
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project is-even (33ms)
|
||||
NX Successfully ran target build for project is-even (33ms)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
|
||||
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
|
||||
|
||||
```
|
||||
|
||||
@@ -236,25 +236,25 @@ Note that the cache for the `build` script was already populated when we ran it
|
||||
To run the `build` target for all the packages in the workspace, use:
|
||||
|
||||
```{% command="npx nx run-many -t build" %}
|
||||
✔ nx run is-even:build [existing outputs match the cache, left as is]
|
||||
✔ nx run is-odd:build [existing outputs match the cache, left as is]
|
||||
✔ nx run is-even:build [existing outputs match the cache, left as is]
|
||||
✔ nx run is-odd:build [existing outputs match the cache, left as is]
|
||||
|
||||
————————————————————————————————————————————————————————————————————————————————————————
|
||||
————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 2 projects (35ms)
|
||||
NX Successfully ran target build for 2 projects (35ms)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 2 out of 2 tasks.
|
||||
Nx read the output from the cache instead of running the command for 2 out of 2 tasks.
|
||||
```
|
||||
|
||||
Notice that both builds are replayed from cache. We can skip the cache by adding the `--skip-nx-cache` option:
|
||||
|
||||
```{% command="npx nx run-many -t build --skip-nx-cache" %}
|
||||
✔ nx run is-even:build (1s)
|
||||
✔ nx run is-odd:build (1s)
|
||||
✔ nx run is-even:build (1s)
|
||||
✔ nx run is-odd:build (1s)
|
||||
|
||||
———————————————————————————————————————————————————————————————————————
|
||||
———————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 2 projects (2s)
|
||||
NX Successfully ran target build for 2 projects (2s)
|
||||
```
|
||||
|
||||
Notice that using this method, the `is-even` build ran before the `is-odd` build, and that the `is-even` build only happened once. This demonstrates how `run-many` is informed by the `targetDefaults` we set earlier.
|
||||
@@ -263,17 +263,17 @@ You can also only run tasks on packages that got changed by using the command:
|
||||
|
||||
```{% command="npx nx affected -t build" %}
|
||||
|
||||
> NX Affected criteria defaulted to --base=main --head=HEAD
|
||||
NX Affected criteria defaulted to --base=main --head=HEAD
|
||||
|
||||
|
||||
✔ nx run is-even:build [existing outputs match the cache, left as is]
|
||||
✔ nx run is-odd:build [existing outputs match the cache, left as is]
|
||||
✔ nx run is-even:build [existing outputs match the cache, left as is]
|
||||
✔ nx run is-odd:build [existing outputs match the cache, left as is]
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for 2 projects (34ms)
|
||||
NX Successfully ran target build for 2 projects (34ms)
|
||||
|
||||
Nx read the output from the cache instead of running the command for 2 out of 2 tasks.
|
||||
Nx read the output from the cache instead of running the command for 2 out of 2 tasks.
|
||||
```
|
||||
|
||||
Notice that the `base` and `head` options were populated with their default values. You could provide your own options here as needed. Notice too that the cache is also used with the `affected` command.
|
||||
|
||||
@@ -33,7 +33,7 @@ In any Nx workspace, you can install `@nx/angular` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/angular
|
||||
```
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ In any Nx workspace, you can install `@nx/cypress` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/cypress
|
||||
```
|
||||
|
||||
@@ -75,6 +75,30 @@ The `@nx/cypress/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
|
||||
The `@nx/cypress/plugin` will automatically split your e2e tasks by file. You can read more about this feature [here](/ci/features/split-e2e-tasks).
|
||||
|
||||
To enable e2e task splitting, make sure there is a `ciWebServerCommand` property set in your `cypress.config.ts` file. It will look something like this:
|
||||
|
||||
```ts {% fileName="apps/my-project-e2e/cypress.config.ts" highlightLines=[13] %}
|
||||
import { defineConfig } from 'cypress';
|
||||
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
...nxE2EPreset(__filename, {
|
||||
cypressDir: 'src',
|
||||
bundler: 'vite',
|
||||
webServerCommands: {
|
||||
default: 'nx run my-project:serve',
|
||||
production: 'nx run my-project:preview',
|
||||
},
|
||||
ciWebServerCommand: 'nx run my-project:serve-static',
|
||||
}),
|
||||
baseUrl: 'http://localhost:4200',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Note: The `nxE2EPreset` is a collection of default settings, but is not necessary for task splitting.
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
|
||||
@@ -95,18 +119,18 @@ By default, when creating a new frontend application, Nx will use Cypress to cre
|
||||
nx g @nx/web:app frontend
|
||||
```
|
||||
|
||||
### Creating a Cypress E2E project for an existing project
|
||||
### Configure Cypress for an existing project
|
||||
|
||||
To generate an E2E project based on an existing project, run the following generator
|
||||
To configure Cypress for an existing project, run the following generator
|
||||
|
||||
```shell
|
||||
nx g @nx/cypress:configuration your-app-name-e2e --project=your-app-name
|
||||
nx g @nx/cypress:configuration --project=your-app-name
|
||||
```
|
||||
|
||||
Optionally, you can use the `--baseUrl` option if you don't want cypress plugin to serve `your-app-name`.
|
||||
Optionally, you can use the `--baseUrl` option if you don't want the Cypress plugin to serve `your-app-name`.
|
||||
|
||||
```shell
|
||||
nx g @nx/cypress:configuration your-app-name-e2e --baseUrl=http://localhost:4200
|
||||
nx g @nx/cypress:configuration --project=your-app-name --baseUrl=http://localhost:4200
|
||||
```
|
||||
|
||||
Replace `your-app-name` with the app's name as defined in your `tsconfig.base.json` file or the `name` property of your `package.json`.
|
||||
|
||||
@@ -36,7 +36,7 @@ In any Nx workspace, you can install `@nx/detox` by running the following comman
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/detox
|
||||
```
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ In any Nx workspace, you can install `@nx/esbuild` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/esbuild
|
||||
```
|
||||
|
||||
|
||||
@@ -13,10 +13,27 @@ Make sure to install the `@nx/eslint-plugin` version that matches the version of
|
||||
|
||||
In any Nx workspace, you can install `@nx/eslint-plugin` by running the following commands if the package is not already installed:
|
||||
|
||||
```shell
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/eslint-plugin
|
||||
```
|
||||
|
||||
This will install the correct version of `@nx/eslint-plugin`.
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
|
||||
Install the `@nx/eslint-plugin` package with your package manager.
|
||||
|
||||
```shell
|
||||
npm add -D @nx/eslint-plugin
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
{% /tabs %}
|
||||
|
||||
## Included plugins
|
||||
|
||||
The plugin contains the following rule configurations divided into sub-plugins.
|
||||
|
||||
@@ -13,7 +13,7 @@ In any Nx workspace, you can install `@nx/eslint` by running the following comma
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/eslint
|
||||
```
|
||||
|
||||
@@ -57,14 +57,23 @@ The `@nx/eslint/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
- The `targetName` option controls the name of the inferred ESLint tasks. The default name is `lint`.
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
{% tab label="Nx 17" %}
|
||||
|
||||
Install the `@nx/eslint` package with your package manager.
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
npm add -D @nx/eslint
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 17" %}
|
||||
|
||||
Install the `@nx/linter` package with your package manager.
|
||||
|
||||
```shell
|
||||
npm add -D @nx/linter
|
||||
```
|
||||
|
||||
{% /tab %}
|
||||
{% /tabs %}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ In any Nx workspace, you can install `@nx/expo` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/expo
|
||||
```
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ In any Nx workspace, you can install `@nx/express` by running the following comm
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/express
|
||||
```
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ In any Nx workspace, you can install `@nx/jest` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/jest
|
||||
```
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ In any Nx workspace, you can install `@nx/js` by running the following command:
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/js
|
||||
```
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ In any Nx workspace, you can install `@nx/nest` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/nest
|
||||
```
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ In any workspace, you can install `@nx/next` by running the following command:
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/next
|
||||
```
|
||||
|
||||
@@ -60,7 +60,8 @@ The `@nx/next/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
"options": {
|
||||
"buildTargetName": "build",
|
||||
"devTargetName": "dev",
|
||||
"startTargetName": "start"
|
||||
"startTargetName": "start",
|
||||
"serveStaticTargetName": "serve-static"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -70,6 +71,10 @@ The `@nx/next/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
- The `buildTargetName` option controls the name of Next.js' compilation task which compiles the application for production deployment. The default name is `build`.
|
||||
- The `devTargetName` option controls the name of Next.js' development serve task which starts the application in development mode. The default name is `dev`.
|
||||
- The `startTargetName` option controls the name of Next.js' production serve task which starts the application in production mode. The default name is `start`.
|
||||
- The `serveStaticTargetName` option controls the name of Next.js' static export task which exports the application to static HTML files. The default name is `serve-static`.
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
|
||||
{% /tab %}
|
||||
{% tab label="Nx < 18" %}
|
||||
@@ -238,7 +243,7 @@ The library in `dist` is publishable to npm or a private registry.
|
||||
|
||||
### Static HTML Export
|
||||
|
||||
Next.js applications can be statically exported by changing th eoutput inside your Next.js configuration file.
|
||||
Next.js applications can be statically exported by changing the output inside your Next.js configuration file.
|
||||
|
||||
```js {% fileName="apps/my-next-app/next.config.js" %}
|
||||
const nextConfig = {
|
||||
@@ -246,9 +251,50 @@ const nextConfig = {
|
||||
nx: {
|
||||
svgr: false,
|
||||
},
|
||||
output: 'export',
|
||||
};
|
||||
```
|
||||
|
||||
After setting the output to `export`, you can run the `build` command to generate the static HTML files.
|
||||
|
||||
```shell
|
||||
nx build my-next-app
|
||||
```
|
||||
|
||||
You can then check your project folder for the `out` folder which contains the static HTML files.
|
||||
|
||||
```shell
|
||||
├── index.d.ts
|
||||
├── jest.config.ts
|
||||
├── next-env.d.ts
|
||||
├── next.config.js
|
||||
├── out
|
||||
├── project.json
|
||||
├── public
|
||||
├── specs
|
||||
├── src
|
||||
├── tsconfig.json
|
||||
└── tsconfig.spec.json
|
||||
```
|
||||
|
||||
#### E2E testing
|
||||
|
||||
You can perform end-to-end (E2E) testing on static HTML files using a test runner like Cypress. When you create a Next.js application, Nx automatically creates a `serve-static` target. This target is designed to serve the static HTML files produced by the build command.
|
||||
|
||||
This feature is particularly useful for testing in continuous integration (CI) pipelines, where resources may be constrained. Unlike the `dev` and `start` targets, `serve-static` does not require a Next.js server to operate, making it more efficient and faster by eliminating background processes, such as file change monitoring.
|
||||
|
||||
To utilize the `serve-static` target for testing, run the following command:
|
||||
|
||||
```shell
|
||||
nx serve-static my-next-app-e2e
|
||||
```
|
||||
|
||||
This command performs several actions:
|
||||
|
||||
1. It will build the Next.js application and generate the static HTML files.
|
||||
2. It will serve the static HTML files using a simple HTTP server.
|
||||
3. It will run the Cypress tests against the served static HTML files.
|
||||
|
||||
### Deploying Next.js Applications
|
||||
|
||||
Once you are ready to deploy your Next.js application, you have absolute freedom to choose any hosting provider that fits your needs.
|
||||
|
||||
@@ -13,7 +13,7 @@ In any Nx workspace, you can install `@nx/node` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/node
|
||||
```
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ Make sure to install the `@nx/nuxt` version that matches the version of `nx` in
|
||||
|
||||
In any Nx workspace, you can install `@nx/nuxt` by running the following command:
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/nuxt
|
||||
```
|
||||
|
||||
@@ -56,7 +56,9 @@ The `@nx/nuxt/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
"options": {
|
||||
"buildTargetName": "build",
|
||||
"testTargetName": "test",
|
||||
"serveTargetName": "serve"
|
||||
"serveTargetName": "serve",
|
||||
"buildStaticTargetName": "build-static",
|
||||
"serveStaticTargetName": "serve-static"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -65,6 +67,8 @@ The `@nx/nuxt/plugin` is configured in the `plugins` array in `nx.json`.
|
||||
|
||||
- The `buildTargetName`, `testTargetName` and `serveTargetName` options control the names of the inferred Nuxt tasks. The default names are `build`, `test` and `serve`.
|
||||
|
||||
The `buildStaticTargetName` and `serveStaticTargetName` options control the names of the inferred Nuxt static tasks. The default names are `build-static` and `serve-static`.
|
||||
|
||||
## Using Nuxt
|
||||
|
||||
### Generate a new Nuxt app
|
||||
@@ -78,3 +82,23 @@ nx g @nx/nuxt:app my-app
|
||||
Once you are ready to deploy your Nuxt application, you have absolute freedom to choose any hosting provider that fits your needs.
|
||||
|
||||
We have detailed [how to deploy your Nuxt application to Vercel in a separate guide](/recipes/nuxt/deploy-nuxt-to-vercel).
|
||||
|
||||
### E2E testing
|
||||
|
||||
By default `nuxt` **does not** generate static HTML files when you run the `build` command. However, Nx provides a `build-static` target that you can use to generate static HTML files for your Nuxt application. Essentially, this target runs the `nuxt build --prerender` command to generate static HTML files.
|
||||
|
||||
To perform end-to-end (E2E) testing on static HTML files using a test runner like Cypress. When you create a Nuxt application, Nx automatically creates a `serve-static` target. This target is designed to serve the static HTML files produced by the `build-static` command.
|
||||
|
||||
This feature is particularly useful for testing in continuous integration (CI) pipelines, where resources may be constrained. Unlike the `serve` target, `serve-static` does not require a Nuxt's Nitro server to operate, making it more efficient and faster by eliminating background processes, such as file change monitoring.
|
||||
|
||||
To utilize the `serve-static` target for testing, run the following command:
|
||||
|
||||
```shell
|
||||
nx serve-static my-nuxt-app-e2e
|
||||
```
|
||||
|
||||
This command performs several actions:
|
||||
|
||||
1. It will build the Nuxt application and generate the static HTML files.
|
||||
2. It will serve the static HTML files using a simple HTTP server.
|
||||
3. It will run the Cypress tests against the served static HTML files.
|
||||
|
||||
@@ -24,7 +24,7 @@ In any Nx workspace, you can install `@nx/playwright` by running the following c
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/playwright
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ The `@nx/playwright/plugin` will automatically split your e2e tasks by file. You
|
||||
|
||||
Install the `@nx/playwright` package with your package manager.
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
npm add -D @nx/playwright
|
||||
```
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ In any Nx workspace, you can install `@nx/react-native` by running the following
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/react-native
|
||||
```
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ In any Nx workspace, you can install `@nx/react` by running the following comman
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/react
|
||||
```
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ In any Nx workspace, you can install `@nx/remix` by running the following comman
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/remix
|
||||
```
|
||||
|
||||
@@ -89,7 +89,7 @@ The command below uses the `as-provided` directory flag behavior, which is the d
|
||||
{% /callout %}
|
||||
|
||||
```{% command="nx g @nx/remix:app myapp --directory=apps/myapp" path="~/acme" %}
|
||||
> NX Generating @nx/remix:application
|
||||
NX Generating @nx/remix:application
|
||||
|
||||
✔ What unit test runner should be used? · vitest
|
||||
|
||||
@@ -135,9 +135,9 @@ Building Remix app in production mode...
|
||||
|
||||
Built in 857ms
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target build for project myapp (3s)
|
||||
NX Successfully ran target build for project myapp (3s)
|
||||
```
|
||||
|
||||
2. To serve your application for use during development run:
|
||||
@@ -155,18 +155,18 @@ Remix App Server started at http://localhost:3000 (http://192.168.0.14:3000)
|
||||
```{% command="nx test myapp" path="~/acme" %}
|
||||
> nx run myapp:test
|
||||
|
||||
RUN v0.31.4 /Users/columferry/dev/nrwl/issues/remixguide/acme/apps/myapp
|
||||
RUN v0.31.4 /Users/columferry/dev/nrwl/issues/remixguide/acme/apps/myapp
|
||||
stderr | app/routes/index.spec.ts > test > should render
|
||||
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
|
||||
✓ app/routes/index.spec.ts (1 test) 10ms
|
||||
Test Files 1 passed (1)
|
||||
Tests 1 passed (1)
|
||||
Start at 16:15:45
|
||||
Duration 1.20s (transform 51ms, setup 139ms, collect 180ms, tests 10ms, environment 379ms, prepare 103ms)
|
||||
✓ app/routes/index.spec.ts (1 test) 10ms
|
||||
Test Files 1 passed (1)
|
||||
Tests 1 passed (1)
|
||||
Start at 16:15:45
|
||||
Duration 1.20s (transform 51ms, setup 139ms, collect 180ms, tests 10ms, environment 379ms, prepare 103ms)
|
||||
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
> NX Successfully ran target test for project myapp (2s)
|
||||
NX Successfully ran target test for project myapp (2s)
|
||||
```
|
||||
|
||||
## Generating an Nx Library
|
||||
@@ -176,7 +176,7 @@ When developing your application, it often makes sense to split your codebase in
|
||||
To generate a library to use in your Remix application run:
|
||||
|
||||
```{% command="nx g @nx/remix:lib login --directory=libs/login" path="~/acme" %}
|
||||
> NX Generating @nx/remix:library
|
||||
NX Generating @nx/remix:library
|
||||
|
||||
✔ What test runner should be used? · vitest
|
||||
UPDATE nx.json
|
||||
@@ -223,7 +223,7 @@ You can also run test on your library:
|
||||
To generate a route for your application:
|
||||
|
||||
```{% command="nx g @nx/remix:route admin --path=apps/myapp/app/routes" path="~/acme" %}
|
||||
> NX Generating @nx/remix:route
|
||||
NX Generating @nx/remix:route
|
||||
|
||||
CREATE apps/myapp/app/routes/admin.tsx
|
||||
CREATE apps/myapp/app/styles/admin.css
|
||||
@@ -236,7 +236,7 @@ To use a Route Loader where the logic lives in your library, follow the steps be
|
||||
1. Generate a loader for your route:
|
||||
|
||||
```{% command="nx g @nx/remix:loader admin --path=apps/myapp/app/routes" path="~/acme" %}
|
||||
> NX Generating @nx/remix:loader
|
||||
NX Generating @nx/remix:loader
|
||||
|
||||
UPDATE apps/myapp/app/routes/admin.tsx
|
||||
```
|
||||
|
||||
@@ -20,7 +20,7 @@ In any Nx workspace, you can install `@nx/storybook` by running the following co
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/storybook
|
||||
```
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ In any Nx workspace, you can install `@nx/vite` by running the following command
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/vite
|
||||
```
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ In any Nx workspace, you can install `@nx/vue` by running the following command:
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/vue
|
||||
```
|
||||
|
||||
@@ -37,7 +37,7 @@ This will install the correct version of `@nx/vue`.
|
||||
|
||||
Install the `@nx/vue` package with your package manager.
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
npm add -D @nx/vue
|
||||
```
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ In any Nx workspace, you can install `@nx/web` by running the following command:
|
||||
{% tabs %}
|
||||
{% tab label="Nx 18+" %}
|
||||
|
||||
```shell
|
||||
```shell {% skipRescope=true %}
|
||||
nx add @nx/web
|
||||
```
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user