project.json:

1//... 2"my-app": { 3 "targets": { 4 //... 5 "build": { 6 "executor": "@nx/vite:build", 7 //... 8 //... 9 "options": { 10 "outputPath": "dist/apps/my-app" 11 }, 12 //... 13 } 14 }, 15 } 16} 17
Nx 15 and lower use @nrwl/ instead of @nx/
1nx serve my-app 2

Examples

Nx will automatically look in the root of your application for a vite.config.ts (or a vite.config.js) file. If you want to use a different path, you can set it in your project.json file, in the build target options:

1//... 2"my-app": { 3 "targets": { 4 //... 5 "build": { 6 "executor": "@nx/vite:build", 7 //... 8 "options": { 9 "outputPath": "dist/apps/my-app", 10 "configFile": "apps/my-app/vite.config.other-path.ts" 11 }, 12 "configurations": { 13 ... 14 } 15 }, 16 } 17} 18
Nx 15 and lower use @nrwl/ instead of @nx/

or even

1//... 2"my-app": { 3 "targets": { 4 //... 5 "build": { 6 "executor": "@nx/vite:build", 7 //... 8 "options": { 9 "outputPath": "dist/apps/my-app", 10 "configFile": "vite.config.base.ts" 11 }, 12 "configurations": { 13 ... 14 } 15 }, 16 } 17} 18
Nx 15 and lower use @nrwl/ instead of @nx/

Options

outputPath

string

The output path of the generated files.

buildLibsFromSource

boolean
Default: true

Read buildable libraries from source instead of building them separately.

configFile

string

The name of the Vite.js configuration file.

fileReplacements

Default: []

Replace files with other files in the build.

generatePackageJson

boolean

Generate a package.json for the build output.

includeDevDependenciesInPackageJson

boolean

Include devDependencies in the generated package.json.

skipTypeCheck

boolean
Default: false

Skip type-checking via TypeScript. Skipping type-checking speeds up the build but type errors are not caught.

watch

oneOf [boolean, object: object]
Default: false

Enable re-building when files change.