Add a `watchDependencies` options to the relevant webpack executors and plugins to allow opting out of watching buildable dependencies. ## Current Behavior ## Expected Behavior ## Related Issue(s) Fixes #29961
172 lines
9.9 KiB
JSON
172 lines
9.9 KiB
JSON
{
|
|
"name": "dev-server",
|
|
"implementation": "/packages/angular/src/builders/dev-server/dev-server.impl.ts",
|
|
"schema": {
|
|
"version": 2,
|
|
"outputCapture": "direct-nodejs",
|
|
"$schema": "http://json-schema.org/draft-07/schema",
|
|
"title": "Schema for Webpack Dev Server",
|
|
"description": "Serves an Angular application using [webpack](https://webpack.js.org/) when the build target is using a webpack-based executor, or [Vite](https://vitejs.dev/) when the build target uses an [esbuild](https://esbuild.github.io/)-based executor.",
|
|
"examplesFile": "This executor is a drop-in replacement for the `@angular-devkit/build-angular:dev-server` builder provided by the Angular CLI. In addition to the features provided by the Angular CLI builder, the `@nx/angular:dev-server` executor also supports the following:\n\n- Serving applications with Vite when using the `@nx/angular:application` or `@nx/angular:browser-esbuild` executors to build them\n- Serving applications with webpack when using the `@nx/angular:webpack-browser` executor\n- Providing HTTP request middleware functions when the build target is using an esbuild-based executor\n- Incremental builds\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Using a custom webpack configuration\" %}\n\nThis executor should be used along with `@nx/angular:webpack-browser` to serve an application using a custom webpack configuration.\n\nAdd the `serve` target using the `@nx/angular:dev-server` executor, set the `build` target executor as `@nx/angular:webpack-browser` and set the `customWebpackConfig` option as shown below:\n\n```json {% fileName=\"apps/my-app/project.json\" highlightLines=[2,\"5-7\",\"10-20\"] %}\n\"build\": {\n \"executor\": \"@nx/angular:webpack-browser\",\n \"options\": {\n ...\n \"customWebpackConfig\": {\n \"path\": \"apps/my-app/webpack.config.js\"\n }\n }\n},\n\"serve\": {\n \"executor\": \"@nx/angular:dev-server\",\n \"configurations\": {\n \"production\": {\n \"buildTarget\": \"my-app:build:production\"\n },\n \"development\": {\n \"buildTarget\": \"my-app:build:development\"\n }\n },\n \"defaultConfiguration\": \"development\",\n}\n```\n\n```js {% fileName=\"apps/my-app/webpack.config.js\" %}\nmodule.exports = (config) => {\n // update the config with your custom configuration\n\n return config;\n};\n```\n\n{% /tab %}\n\n{% tab label=\"Providing HTTP request middleware function\" %}\n\n{% callout type=\"warning\" title=\"Overrides\" }\n\nAvailable for workspaces using Angular version 17.0.0 or greater and with `build` targets using an esbuild-based executor.\n\n{% /callout %}\n\nThe executor accepts an `esbuildMiddleware` option that allows you to provide HTTP require middleware functions that will be used by the Vite development server.\n\n```json {% fileName=\"apps/my-app/project.json\" highlightLines=[8] %}\n{\n ...\n \"targets\": {\n \"serve\": {\n \"executor\": \"@nx/angular:dev-server\",\n \"options\": {\n ...\n \"esbuildMiddleware\": [\"apps/my-app/hello-world.middleware.ts\"]\n }\n }\n ...\n }\n}\n```\n\n```ts {% fileName=\"apps/my-app/hello-world.middleware.ts\" %}\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nconst helloWorldMiddleware = (\n req: IncomingMessage,\n res: ServerResponse,\n next: (err?: unknown) => void\n) => {\n if (req.url === '/hello-world') {\n res.end('<h1>Hello World!</h1>');\n } else {\n next();\n }\n};\n\nexport default helloWorldMiddleware;\n```\n\n{% /tab %}\n",
|
|
"type": "object",
|
|
"presets": [
|
|
{ "name": "Using a Different Port", "keys": ["buildTarget", "port"] }
|
|
],
|
|
"properties": {
|
|
"browserTarget": {
|
|
"type": "string",
|
|
"description": "A browser builder target to serve in the format of `project:target[:configuration]`. Ignored if `buildTarget` is set.",
|
|
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$",
|
|
"x-deprecated": "Use 'buildTarget' instead. It will be removed in Nx v20."
|
|
},
|
|
"buildTarget": {
|
|
"type": "string",
|
|
"description": "A build builder target to serve in the format of `project:target[:configuration]`.",
|
|
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$"
|
|
},
|
|
"port": {
|
|
"type": "number",
|
|
"description": "Port to listen on.",
|
|
"default": 4200
|
|
},
|
|
"host": {
|
|
"type": "string",
|
|
"description": "Host to listen on.",
|
|
"default": "localhost"
|
|
},
|
|
"proxyConfig": {
|
|
"type": "string",
|
|
"description": "Proxy configuration file. For more information, see https://angular.dev/tools/cli/serve#proxying-to-a-backend-server."
|
|
},
|
|
"ssl": {
|
|
"type": "boolean",
|
|
"description": "Serve using HTTPS.",
|
|
"default": false
|
|
},
|
|
"sslKey": {
|
|
"type": "string",
|
|
"description": "SSL key to use for serving HTTPS."
|
|
},
|
|
"sslCert": {
|
|
"type": "string",
|
|
"description": "SSL certificate to use for serving HTTPS."
|
|
},
|
|
"headers": {
|
|
"type": "object",
|
|
"description": "Custom HTTP headers to be added to all responses.",
|
|
"propertyNames": { "pattern": "^[-_A-Za-z0-9]+$" },
|
|
"additionalProperties": { "type": "string" }
|
|
},
|
|
"open": {
|
|
"type": "boolean",
|
|
"description": "Opens the url in default browser.",
|
|
"default": false,
|
|
"alias": "o"
|
|
},
|
|
"verbose": {
|
|
"type": "boolean",
|
|
"description": "Adds more details to output logging."
|
|
},
|
|
"liveReload": {
|
|
"type": "boolean",
|
|
"description": "Whether to reload the page on change, using live-reload.",
|
|
"default": true
|
|
},
|
|
"publicHost": {
|
|
"type": "string",
|
|
"description": "The URL that the browser client (or live-reload client, if enabled) should use to connect to the development server. Use for a complex dev server setup, such as one with reverse proxies."
|
|
},
|
|
"allowedHosts": {
|
|
"type": "array",
|
|
"description": "List of hosts that are allowed to access the dev server.",
|
|
"default": [],
|
|
"items": { "type": "string" }
|
|
},
|
|
"servePath": {
|
|
"type": "string",
|
|
"description": "The pathname where the app will be served."
|
|
},
|
|
"disableHostCheck": {
|
|
"type": "boolean",
|
|
"description": "Don't verify connected clients are part of allowed hosts.",
|
|
"default": false
|
|
},
|
|
"hmr": {
|
|
"type": "boolean",
|
|
"description": "Enable hot module replacement. It defaults to `false` in Angular versions < 19.0.0. Otherwise, the value will be `undefined`."
|
|
},
|
|
"watch": {
|
|
"type": "boolean",
|
|
"description": "Rebuild on change.",
|
|
"default": true
|
|
},
|
|
"poll": {
|
|
"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.",
|
|
"default": false
|
|
},
|
|
"inspect": {
|
|
"default": false,
|
|
"description": "Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are enabled. _Note: this is only supported in Angular versions >= 18.1.0_.",
|
|
"oneOf": [
|
|
{
|
|
"type": "string",
|
|
"description": "Activate the inspector on host and port in the format of `[[host:]port]`. See the security warning in https://nodejs.org/docs/latest-v22.x/api/cli.html#warning-binding-inspector-to-a-public-ipport-combination-is-insecure regarding the host parameter usage."
|
|
},
|
|
{ "type": "boolean" }
|
|
]
|
|
},
|
|
"prebundle": {
|
|
"description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled. This option has no effect when using the 'browser' or other Webpack-based builders. _Note: this is only supported in Angular versions >= 17.2.0_.",
|
|
"oneOf": [
|
|
{ "type": "boolean" },
|
|
{
|
|
"type": "object",
|
|
"properties": {
|
|
"exclude": {
|
|
"description": "List of package imports that should not be prebundled by the development server. The packages will be bundled into the application code itself.",
|
|
"type": "array",
|
|
"items": { "type": "string" }
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"required": ["exclude"]
|
|
}
|
|
]
|
|
},
|
|
"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.",
|
|
"x-priority": "important"
|
|
},
|
|
"esbuildMiddleware": {
|
|
"description": "A list of HTTP request middleware functions.",
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string",
|
|
"description": "The path to the middleware function. Relative to the workspace root."
|
|
}
|
|
},
|
|
"watchDependencies": {
|
|
"type": "boolean",
|
|
"description": "Watch buildable dependencies and rebuild when they change.",
|
|
"default": true
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"anyOf": [
|
|
{ "required": ["buildTarget"] },
|
|
{ "required": ["browserTarget"] }
|
|
]
|
|
},
|
|
"description": "Serves an Angular application using [webpack](https://webpack.js.org/) when the build target is using a webpack-based executor, or [Vite](https://vitejs.dev/) when the build target uses an [esbuild](https://esbuild.github.io/)-based executor.",
|
|
"aliases": [],
|
|
"hidden": false,
|
|
"path": "/packages/angular/src/builders/dev-server/schema.json",
|
|
"type": "executor"
|
|
}
|