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/react: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

buildTarget

string

Target which builds the application.

devRemotes

devProducers
Array<oneOf [string, object ]>

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

open

boolean
Default: false

Open the application in the browser.

port

number
Default: 4200

Port to listen on.

skipRemotes

skipProducers
Array<string>

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

allowedHosts

string

This option allows you to whitelist services that are allowed to access the dev server.

baseHref

string

Base url for the application being built.

host

string
Default: localhost

Host to listen on.

hmr

boolean
Default: false

Enable hot module replacement.

liveReload

boolean
Default: true

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

memoryLimit

number

Memory limit for type checking service process in MB.

maxWorkers

number

Number of workers to use for type checking.

publicHost

string

Public URL where the application will be served.

parallel

number

Max number of parallel processes for building static Producers (remotes)

pathToManifestFile

string

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

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.

static

boolean

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

staticRemotesPort

staticProducersPort
number

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

watch

boolean
Default: true

Watches for changes and rebuilds application.

isInitialHost

isInitialConsumerInternal
boolean
Default: true

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