- Update `/packages/` links to `/nx-api/` - Convert some unneeded absolute links to relative - Remove leftover examples doc for the already removed `cypress-project` generator <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #26126
2.2 KiB
| title | description |
|---|---|
| JS Node executor examples | This page contains examples for the @nx/js:node executor. |
The @nx/js:node executor runs the output of a build target. For example, an application uses esbuild (@nx/esbuild:esbuild) to output the bundle to dist/my-app folder, which can then be executed by @nx/js:node.
project.json:
"my-app": {
"targets": {
"serve": {
"executor": "@nx/js:node",
"options": {
"buildTarget": "my-app:build"
}
},
"build": {
"executor": "@nx/esbuild:esbuild",
"options": {
"main": "my-app/src/main.ts",
"output": ["dist/my-app"],
//...
}
},
}
}
npx nx serve my-app
Examples
{% tabs %} {% tab label="Pass extra Node CLI arguments" %}
Using runtimeArgs, you can pass arguments to the underlying node command. For example, if you want to set --no-warnings to silence all Node warnings, then add the following to the project.json file.
"my-app": {
"targets": {
"serve": {
"executor": "@nx/js:node",
"options": {
"runtimeArgs": ["--no-warnings"],
//...
},
},
}
}
{% /tab %}
{% tab label="Run all task dependencies" %}
If your application build depends on other tasks, and you want those tasks to also be executed, then set the runBuildTargetDependencies to true. For example, a library may have a task to generate GraphQL schemas, which is consume by the application. In this case, you want to run the generate task before building and running the application.
This option is also useful when the build consumes a library from its output, not its source. For example, if an executor that supports buildLibsFromSource option has it set to false (e.g. @nx/webpack:webpack).
Note that this option will increase the build time, so use it only when necessary.
"my-app": {
"targets": {
"serve": {
"executor": "@nx/js:node",
"options": {
"runBuildTargetDependencies": true,
//...
},
},
}
}
{% /tab %}
{% /tabs %}