Examples

The Module Federation Dev Server will serve a host application and find the remote applications associated with the host and serve them statically also.
See an example set up of it below:

1{ 2 "serve": { 3 "executor": "@nx/angular:module-federation-dev-server", 4 "configurations": { 5 "production": { 6 "buildTarget": "host:build:production" 7 }, 8 "development": { 9 "buildTarget": "host:build:development" 10 } 11 }, 12 "defaultConfiguration": "development", 13 "options": { 14 "port": 4200, 15 "publicHost": "http://localhost:4200" 16 } 17 } 18} 19

Options

Mixins

This type has all of the properties below, but must also match this type:

anyOf [required: buildTarget, required: browserTarget]

buildLibsFromSource

boolean

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.

devRemotes

Array<oneOf [string, object ]>

List of remote applications to run in development mode (i.e. using serve target).

allowedHosts

Array<string>
Default: []

List of hosts that are allowed to access the dev server.

buildTarget

string
Pattern: ^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$

A build builder target to serve in the format of project:target[:configuration].

disableHostCheck

boolean
Default: false

Don't verify connected clients are part of allowed hosts.

host

string
Default: localhost

Host to listen on.

headers

Custom HTTP headers to be added to all responses.

hmr

boolean
Default: false

Enable hot module replacement.

liveReload

boolean
Default: true

Whether to reload the page on change, using live-reload.

open

o
boolean
Default: false

Opens the url in default browser.

port

number
Default: 4200

Port to listen on.

proxyConfig

string

Proxy configuration file. For more information, see https://angular.dev/tools/cli/serve#proxying-to-a-backend-server.

publicHost

string

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.

poll

number

Enable and define the file watching poll time period in milliseconds.

pathToManifestFile

string

Path to a Module Federation manifest file (e.g. my/path/to/module-federation.manifest.json) containing the dynamic remote applications relative to the workspace root.

parallel

number

Max number of parallel processes for building static remotes

ssl

boolean
Default: false

Serve using HTTPS.

sslKey

string

SSL key to use for serving HTTPS.

sslCert

string

SSL certificate to use for serving HTTPS.

servePath

string

The pathname where the app will be served.

skipRemotes

Array<string>

List of remote applications to not automatically serve, either statically or in development mode. This will not remove the remotes from the module-federation.config file, and therefore the application may still try to fetch these remotes. This option is useful if you have other means for serving the remote application(s). NOTE: Remotes that are not in the workspace will be skipped automatically.

static

boolean

Whether to use a static file server instead of the webpack-dev-server. This should be used for remote applications that are also host applications.

staticRemotesPort

number

The port at which to serve the file-server for the static remotes.

verbose

boolean

Adds more details to output logging.

watch

boolean
Default: true

Rebuild on change.

isInitialHost

Internal
boolean
Default: true

Whether the host that is running this executor is the first in the project tree to do so.

browserTarget

Deprecated
string
Pattern: ^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$

A browser builder target to serve in the format of project:target[:configuration].

Use 'buildTarget' instead. It will be removed in Nx v20.