@nrwl/vite:preview-server

Preview 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": { //... "preview": { "executor": "@nrwl/vite:preview-server", "defaultConfiguration": "development", "options": { "buildTarget": "my-app:build", }, "configurations": { ... } }, } }
nx preview 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 preview target options:

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

Options

buildTarget

Required
string

Target which builds the application.

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.

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.