@nrwl/vite:dev-server

Dev server for Vite.

Options can be configured in project.json when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.

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.

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.

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.

port

number

Port to listen on.