project.json:

1//... 2"my-app": { 3 "targets": { 4 //... 5 "serve": { 6 "executor": "@nx/vite:dev-server", 7 "defaultConfiguration": "development", 8 "options": { 9 "buildTarget": "my-app:build", 10 }, 11 "configurations": { 12 ... 13 } 14 }, 15 } 16} 17
1nx serve my-app 2

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:

1//... 2"my-app": { 3 "targets": { 4 //... 5 "serve": { 6 "executor": "@nx/vite:dev-server", 7 "defaultConfiguration": "development", 8 "options": { 9 "buildTarget": "my-app:build", 10 "port": 4200, 11 }, 12 "configurations": { 13 ... 14 } 15 }, 16 } 17} 18

Options

buildTarget

Required
string

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

buildLibsFromSource

boolean
Default: true

Read buildable libraries from source instead of building them separately.

proxyConfig

string

Path to the proxy configuration file.