-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update getting started guide; add migration docs for inferred targets and package executor; add plugin concept docs
- Loading branch information
Showing
10 changed files
with
258 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Plugin concepts | ||
|
||
This page summarizes the main Nx Forge plugin concepts and ideas. | ||
|
||
## Building Forge apps | ||
|
||
When using [the app generator](../guides/generating-a-forge-app.md) to scaffold a Forge app, you will get a Nx project with a build target and a collection of inferred targets provided by the Nx Forge plugin. | ||
|
||
The most important thing to know is that to deploy a Forge app, you need to run the following executors to get an artifact that can be deployed to the Forge platform: | ||
|
||
::: tip Executors to get a deployable Forge app artifact | ||
|
||
build -> package | ||
|
||
::: | ||
|
||
The `build` target is meant to compile and bundle the app's Typescript code. This can be done by any standard Nx plugin that supports bundling node applications, for example `@nx/webpack` or `@nx/esbuild`. The main Forge requirement is that the output is produced into a `src` directory (a Forge CLI quirk, probably because the CLI itself wants to support Typescript compilation and bundle the code). | ||
|
||
The `package` target is provided by Nx Forge and completes the output generated by the `build` target to an artifact that can be deployed to the Forge platform. This includes, copying the manifest.yml file to the output, copying the outputs of dependent resource project (Custom UI or UI Kit) to the Forge app, as well as generating a package.json file that includes all the Forge app dependencies. | ||
|
||
Once, the `build` and `package` stages have run, the Forge app can be deployed. Because it is so common to run these tasks in sequence, it is worth [defining target defaults for them](../guides/getting-started.md#configuring-target-defaults). Nx caches builds, so there is hardly any overhead to always running when calling the `deploy` target. | ||
|
||
## Plugin targets | ||
|
||
The Nx Forge plugin provides [a set of executors](../reference/executors.md) that assist with developing, building and deploying Forge apps in a Nx workspace. The plugin provides specific [`register`](../reference/executors.md#register) or [`deploy`](../reference/executors.md#deploy) executors which should be used over the Forge CLI command. They facilitate the integration with the Nx workspace and provide additional features. | ||
In cases where the plugin does not provide specific executors, it is recommended to use the [`forge`](../reference/executors.md#forge) executor to invoke the Forge CLI. This will ensure that the command runs from the app's output directory in the Nx workspace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Migrating to inferred tasks | ||
|
||
Since Nx version 18, Nx plugins can automatically infer tasks for your projects based on the configuration of different tools. Refer to the [Nx docs on inferred tasks (Project Crystal)](https://nx.dev/concepts/inferred-tasks) for more details. | ||
|
||
::: tip Nx Console | ||
|
||
If you are not using Nx Console yet, we [highly recommend installing it](./getting-started.md#installing-nx-console) when moving to inferred tasks as it helps you discover tasks and run them from your IDE's user interface. | ||
|
||
::: | ||
|
||
Staring with Nx Forge plugin version 4.0.0, the plugin could infer targets for Forge app projects and since plugin version 5.1.0, the plugin generates Forge apps with inferred targets. This means, if you generate a new Forge app, you will not see any target definitions in the app's `project.json` file if they can be inferred. | ||
|
||
As of plugin version 5.1.0, all [executor targets provided by the plugin](../reference/executors.md) can be inferred (except for the deprecated `build` executor). This means, to migrate to inferred tasks, you can simply remove those from your app's `project.json` files. | ||
|
||
From our experience, transitioning the configuration to inferred tasks can be tricky. If you run into issues, it often helps to [generate a clean Nx test workspace](./getting-started.md#prerequisites), run the app generators you are interested in and compare the generated configuration in `project.json` files and the `nx.json` with your existing workspace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Migrating to the package executor | ||
|
||
Since plugin version 5.1.0, the existing `build` executor has been deprecated in favor of a Nx native build in combination with the `package` executor. | ||
|
||
For all the details and motivation of this change refer to [the discussion on GitHub](/~https://github.com/toolsplus/nx-forge/discussions/86). | ||
|
||
## Migration steps | ||
|
||
1. Ensure you are on the latest plugin version by running: | ||
|
||
`nx add @toolsplus/nx-forge@latest`. | ||
2. [Generate a new Forge app](./generating-a-forge-app.md) with the updated app generator. Make sure to set the `bundler` option to [choose if the `build` task should be run by Webpack or esbuild](../reference/generators.md#application). You do not need to run the `build`, `package`, or `register` tasks. Generating this Forge app will ensure you have the correct dependencies installed and your workspace is configured to work with Webpack or esbuild. | ||
3. a) If you chose the Webpack bundler option (default): | ||
|
||
Copy the `webpack.config.js` to your app's project directory and update the `output.path` to match your project layout. Delete the existing `build` target configuration. | ||
|
||
b) If you chose the esbuild bundler option: | ||
|
||
Copy the `build` target configuration from the generated app's `project.json` and replace the existing `build` target configuration in your app's `project.json`. Adjust the path configurations in the `build` target to match your project layout. | ||
4. Run `nx g @nx/workspace:remove --projectName=<genrated-forge-app>` to remove the app generated in step 2. |
Oops, something went wrong.