project.json:

//... "my-app": { "targets": { //... "serve": { "executor": "@nrwl/vite:dev-server", "defaultConfiguration": "development", "options": { "buildTarget": "my-app:build", }, "configurations": { ... } }, } }
nx serve my-app

Examples

You can always set the port in your vite.config.ts file. However, you can also set it directly in your project.json file, in the serve target options:

//... "my-app": { "targets": { //... "serve": { "executor": "@nrwl/vite:dev-server", "defaultConfiguration": "development", "options": { "buildTarget": "my-app:build", "port": 4200, }, "configurations": { ... } }, } }

Options

buildTarget

Required
string

Target which builds the application. Only used to retrieve the configuration as the dev-server does not build the code.

port

number

Port to listen on.

cors

boolean

Configure CORS for the dev server.

clearScreen

boolean

Set to false to prevent Vite from clearing the terminal screen when logging certain messages.

force

boolean

Force the optimizer to ignore the cache and re-bundle

host

oneOf [boolean, string]

Specify which IP addresses the server should listen on.

https

boolean

Serve using HTTPS.

hmr

boolean

Enable hot module replacement. For more options, use the 'hmr' option in the Vite configuration file.

logLevel

string
Accepted values: info, warn, error, silent

Adjust console output verbosity.

mode

string

Mode to run the server in.

open

oneOf [boolean, string]

Automatically open the app in the browser on server start. When the value is a string, it will be used as the URL's pathname.

proxyConfig

string

Path to the proxy configuration file.