|
4 | 4 | "schema": {
|
5 | 5 | "$schema": "http://json-schema.org/draft-07/schema",
|
6 | 6 | "title": "Schema for Nx Application Executor",
|
7 |
| - "description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities. _Note: this is only supported in Angular versions >= 17.0.0_.", |
| 7 | + "description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.", |
8 | 8 | "examplesFile": "This executor is a drop-in replacement for the `@angular-devkit/build-angular:application` builder provided by the Angular CLI. It builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.\n\nIn addition to the features provided by the Angular CLI builder, the `@nx/angular:application` executor also supports the following:\n\n- Providing esbuild plugins\n- Providing a function to transform the application's `index.html` file\n- Incremental builds\n\n{% callout type=\"check\" title=\"Dev Server\" %}\nThe [`@nx/angular:dev-server` executor](/nx-api/angular/executors/dev-server) is required to serve your application when using the `@nx/angular:application` to build it. It is a drop-in replacement for the Angular CLI's `@angular-devkit/build-angular:dev-server` builder and ensures the application is correctly served with Vite when using the `@nx/angular:application` executor.\n{% /callout %}\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Providing esbuild plugins\" %}\n\nThe executor accepts a `plugins` option that allows you to provide esbuild plugins that will be used when building your application. It allows providing a path to a plugin file or an object with a `path` and `options` property to provide options to the plugin.\n\n```json {% fileName=\"apps/my-app/project.json\" highlightLines=[\"8-16\"] %}\n{\n ...\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/angular:application\",\n \"options\": {\n ...\n \"plugins\": [\n \"apps/my-app/plugins/plugin1.js\",\n {\n \"path\": \"apps/my-app/plugins/plugin2.js\",\n \"options\": {\n \"someOption\": \"some value\"\n }\n }\n ]\n }\n }\n ...\n }\n}\n```\n\n```ts {% fileName=\"apps/my-app/plugins/plugin1.js\" %}\nconst plugin1 = {\n name: 'plugin1',\n setup(build) {\n const options = build.initialOptions;\n options.define.PLUGIN1_TEXT = '\"Value was provided at build time\"';\n },\n};\n\nmodule.exports = plugin1;\n```\n\n```ts {% fileName=\"apps/my-app/plugins/plugin2.js\" %}\nfunction plugin2({ someOption }) {\n return {\n name: 'plugin2',\n setup(build) {\n const options = build.initialOptions;\n options.define.PLUGIN2_TEXT = JSON.stringify(someOption);\n },\n };\n}\n\nmodule.exports = plugin2;\n```\n\nAdditionally, we need to inform TypeScript of the defined variables to prevent type-checking errors during the build. We can achieve this by creating or updating a type definition file included in the TypeScript build process (e.g. `src/types.d.ts`) with the following content:\n\n```ts {% fileName=\"apps/my-app/src/types.d.ts\" %}\ndeclare const PLUGIN1_TEXT: number;\ndeclare const PLUGIN2_TEXT: string;\n```\n\n{% /tab %}\n\n{% tab label=\"Transforming the 'index.html' file\" %}\n\nThe executor accepts an `indexHtmlTransformer` option to provide a path to a file with a default export for a function that receives the application's `index.html` file contents and outputs the updated contents.\n\n```json {% fileName=\"apps/my-app/project.json\" highlightLines=[8] %}\n{\n ...\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/angular:application\",\n \"options\": {\n ...\n \"indexHtmlTransformer\": \"apps/my-app/index-html.transformer.ts\"\n }\n }\n ...\n }\n}\n```\n\n```ts {% fileName=\"apps/my-app/index-html.transformer.ts\" %}\nexport default function (indexContent: string) {\n return indexContent.replace(\n '<title>my-app</title>',\n '<title>my-app (transformed)</title>'\n );\n}\n```\n\n{% /tab %}\n{% /tabs %}\n",
|
9 | 9 | "outputCapture": "direct-nodejs",
|
10 | 10 | "type": "object",
|
|
55 | 55 | },
|
56 | 56 | "server": {
|
57 | 57 | "type": "string",
|
58 |
| - "description": "The full path for the server entry point to the application, relative to the current workspace." |
| 58 | + "description": "The full path for the server entry point to the application, relative to the current workspace.", |
| 59 | + "oneOf": [ |
| 60 | + { |
| 61 | + "type": "string", |
| 62 | + "description": "The full path for the server entry point to the application, relative to the current workspace." |
| 63 | + }, |
| 64 | + { |
| 65 | + "const": false, |
| 66 | + "type": "boolean", |
| 67 | + "description": "Indicates that a server entry point is not provided. _Note: this is only supported in Angular versions >= 19.0.0_." |
| 68 | + } |
| 69 | + ] |
59 | 70 | },
|
60 | 71 | "polyfills": {
|
61 | 72 | "description": "A list of polyfills to include in the build. Can be a full path for a file, relative to the current workspace or module specifier. Example: 'zone.js'.",
|
|
71 | 82 | "type": "string",
|
72 | 83 | "description": "Customize the base path for the URLs of resources in 'index.html' and component stylesheets. This option is only necessary for specific deployment scenarios, such as with Angular Elements or when utilizing different CDN locations. _Note: this is only supported in Angular versions >= 17.3.0_."
|
73 | 84 | },
|
| 85 | + "security": { |
| 86 | + "description": "Security features to protect against XSS and other common attacks. _Note: this is only supported in Angular versions >= 19.0.0_.", |
| 87 | + "type": "object", |
| 88 | + "additionalProperties": false, |
| 89 | + "properties": { |
| 90 | + "autoCsp": { |
| 91 | + "description": "Enables automatic generation of a hash-based Strict Content Security Policy (https://web.dev/articles/strict-csp#choose-hash) based on scripts in index.html. Will default to true once we are out of experimental/preview phases. It defaults to `false`.", |
| 92 | + "oneOf": [ |
| 93 | + { |
| 94 | + "type": "object", |
| 95 | + "properties": { |
| 96 | + "unsafeEval": { |
| 97 | + "type": "boolean", |
| 98 | + "description": "Include the `unsafe-eval` directive (https://web.dev/articles/strict-csp#remove-eval) in the auto-CSP. Please only enable this if you are absolutely sure that you need to, as allowing calls to eval will weaken the XSS defenses provided by the auto-CSP. It default to `false`." |
| 99 | + } |
| 100 | + }, |
| 101 | + "additionalProperties": false |
| 102 | + }, |
| 103 | + { "type": "boolean" } |
| 104 | + ] |
| 105 | + } |
| 106 | + } |
| 107 | + }, |
74 | 108 | "scripts": {
|
75 | 109 | "description": "Global scripts to be included in the build.",
|
76 | 110 | "type": "array",
|
|
157 | 191 | "type": "array",
|
158 | 192 | "items": { "type": "string" },
|
159 | 193 | "default": []
|
| 194 | + }, |
| 195 | + "sass": { |
| 196 | + "description": "Options to pass to the sass preprocessor. _Note: this is only supported in Angular versions >= 19.0.0_.", |
| 197 | + "type": "object", |
| 198 | + "properties": { |
| 199 | + "fatalDeprecations": { |
| 200 | + "description": "A set of deprecations to treat as fatal. If a deprecation warning of any provided type is encountered during compilation, the compiler will error instead. If a Version is provided, then all deprecations that were active in that compiler version will be treated as fatal.", |
| 201 | + "type": "array", |
| 202 | + "items": { "type": "string" } |
| 203 | + }, |
| 204 | + "silenceDeprecations": { |
| 205 | + "description": " A set of active deprecations to ignore. If a deprecation warning of any provided type is encountered during compilation, the compiler will ignore it instead.", |
| 206 | + "type": "array", |
| 207 | + "items": { "type": "string" } |
| 208 | + }, |
| 209 | + "futureDeprecations": { |
| 210 | + "description": "A set of future deprecations to opt into early. Future deprecations passed here will be treated as active by the compiler, emitting warnings as necessary.", |
| 211 | + "type": "array", |
| 212 | + "items": { "type": "string" } |
| 213 | + } |
| 214 | + }, |
| 215 | + "additionalProperties": false |
160 | 216 | }
|
161 | 217 | },
|
162 | 218 | "additionalProperties": false
|
|
546 | 602 | "default": []
|
547 | 603 | },
|
548 | 604 | "prerender": {
|
549 |
| - "description": "Prerender (SSG) pages of your application during build time.", |
550 |
| - "default": false, |
| 605 | + "description": "Prerender (SSG) pages of your application during build time. It defaults to `false` in Angular versions < 19.0.0. Otherwise, the value will be `undefined`.", |
551 | 606 | "oneOf": [
|
552 | 607 | {
|
553 | 608 | "type": "boolean",
|
|
584 | 639 | "entry": {
|
585 | 640 | "type": "string",
|
586 | 641 | "description": "The server entry-point that when executed will spawn the web server."
|
| 642 | + }, |
| 643 | + "experimentalPlatform": { |
| 644 | + "description": "Specifies the platform for which the server bundle is generated. This affects the APIs and modules available in the server-side code. \n\n- `node`: (Default) Generates a bundle optimized for Node.js environments. \n- `neutral`: Generates a platform-neutral bundle suitable for environments like edge workers, and other serverless platforms. This option avoids using Node.js-specific APIs, making the bundle more portable. \n\nPlease note that this feature does not provide polyfills for Node.js modules. Additionally, it is experimental, and the feature may undergo changes in future versions. _Note: this is only supported in Angular versions >= 19.0.0_.", |
| 645 | + "default": "node", |
| 646 | + "enum": ["node", "neutral"] |
587 | 647 | }
|
588 | 648 | },
|
589 | 649 | "additionalProperties": false
|
|
592 | 652 | },
|
593 | 653 | "appShell": {
|
594 | 654 | "type": "boolean",
|
595 |
| - "description": "Generates an application shell during build time.", |
596 |
| - "default": false |
| 655 | + "description": "Generates an application shell during build time. It defaults to `false` in Angular versions < 19.0.0. Otherwise, the value will be `undefined`." |
| 656 | + }, |
| 657 | + "outputMode": { |
| 658 | + "type": "string", |
| 659 | + "description": "Defines the build output target. 'static': Generates a static site for deployment on any static hosting service. 'server': Produces an application designed for deployment on a server that supports server-side rendering (SSR). _Note: this is only supported in Angular versions >= 19.0.0_.", |
| 660 | + "enum": ["static", "server"] |
597 | 661 | },
|
598 | 662 | "buildLibsFromSource": {
|
599 | 663 | "type": "boolean",
|
|
739 | 803 | },
|
740 | 804 | "presets": []
|
741 | 805 | },
|
742 |
| - "description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities. _Note: this is only supported in Angular versions >= 17.0.0_.", |
| 806 | + "description": "Builds an Angular application using [esbuild](https://esbuild.github.io/) with integrated SSR and prerendering capabilities.", |
743 | 807 | "aliases": [],
|
744 | 808 | "hidden": false,
|
745 | 809 | "path": "/packages/angular/src/executors/application/schema.json",
|
|
0 commit comments