Schema for internal use only

Please do not extend this schema as it is part of Nx internal usage.

@nx/vite:init

Initialize Vite in the workspace.

This is a generator will initialize Vite.js in your workspace. It will install all the necessary dependencies. You can read more about how this generator works, in the Vite package overview page.

string

You don't need to use this generator on its own.

This generator will be called automatically when you are either converting an existing React or Web app to use Vite, using the @nx/vite:configuration generator, or when you are creating a new React or Web app using the @nx/react:app or @nx/web:app generators, if you choose vite as the bundler.

If you need to for some reason, you can use it on its own like this:

Examples

Install all the necessary dependencies for Vite and the React plugin

1nx g @nx/vite:init --uiFramework=react 2
Nx 15 and lower use @nrwl/ instead of @nx/

Install all the necessary dependencies for Vite

1nx g @nx/vite:init --uiFramework=none 2
Nx 15 and lower use @nrwl/ instead of @nx/

Usage

1nx generate init ... 2
1nx g ng-add ... #same 2

By default, Nx will search for init in the default collection provisioned in workspace.json.

You can specify the collection explicitly as follows:

Show what will be generated without writing to disk:

1nx g init ... --dry-run 2

Options

compiler

string
Default: babel
Accepted values: babel, swc

Compiler to use for Vite when UI Framework is React.

includeLib

boolean
Default: false

Add dependencies needed to build libraries.

testEnvironment

string
Default: jsdom
Accepted values: node, jsdom, happy-dom, edge-runtime

The vitest environment to use. See https://vitest.dev/config/#environment.

uiFramework

string
Default: react
Accepted values: react, none

UI Framework to use for Vite.