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
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

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

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.

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.

skipPackageManager

boolean

Do not add a packageManager entry to the generated package.json file. Only works in conjunction with generatePackageJson option.

tsConfig

string

The path to custom tsconfig file for type-checking when skipTypeCheck is false. Required when tsconfig file is not at the projectRoot level.

watch

oneOf [boolean, object: object]
Default: false

Enable re-building when files change.