project.json:

//... "my-app": { "targets": { //... "build": { "executor": "@nrwl/vite:build", //... //... "options": { "outputPath": "dist/apps/my-app" }, //... } }, } }
nx serve my-app

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:

//... "my-app": { "targets": { //... "build": { "executor": "@nrwl/vite:build", //... "options": { "outputPath": "dist/apps/my-app", "configFile": "apps/my-app/vite.config.other-path.ts" }, "configurations": { ... } }, } }

or even

//... "my-app": { "targets": { //... "build": { "executor": "@nrwl/vite:build", //... "options": { "outputPath": "dist/apps/my-app", "configFile": "vite.config.base.ts" }, "configurations": { ... } }, } }

Options

outputPath

string

The output path of the generated files.

base

baseHref
string

Base public path when served in development or production.

configFile

string

The name of the Vite.js configuration file.

emptyOutDir

boolean
Default: true

When set to false, outputPath will not be emptied during the build process.

fileReplacements

Default: []

Replace files with other files in the build.

force

boolean

Force the optimizer to ignore the cache and re-bundle

generatePackageJson

boolean
Default: falseFormat: {type:string,description:List of module formats to output. Defaults to matching format from tsconfig (e.g. CJS for CommonJS, and ESM otherwise).,alias:f,enum:[esm,cjs],default:esm}

Generates a package.json and pruned lock file with the project's node_module dependencies populated for installing in a container. If a package.json exists in the project's directory, it will be reused with dependencies populated.

logLevel

string
Accepted values: info, warn, error, silent

Adjust console output verbosity.

minify

oneOf [boolean, string]

Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.

manifest

oneOf [boolean, string]

Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.

mode

string

Mode to run the build in.

main

entryFile
string

The path to the entry file, relative to project. Only needed if using generatePackageJson

sourcemap

oneOf [boolean, string]

Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.

ssrManifest

oneOf [boolean, string]

When set to true, the build will also generate an SSR manifest for determining style links and asset preload directives in production. When the value is a string, it will be used as the manifest file name.

ssr

oneOf [boolean, string]

Produce SSR-oriented build. The value can be a string to directly specify the SSR entry, or true, which requires specifying the SSR entry via rollupOptions.input.

tsConfig

string

The path to tsconfig file. Only needed if using generatePacakgeJson

watch

oneOf [boolean, object: object]
Default: false

Enable re-building when files change.