Edit

+root

Environment: config

string


Global

Vike's +root setting is just an alias for Vite's root setting — the project root directory.

It can be absolute, or relative to the current working directory.

You can set it over Vike's CLI:

$ vike dev --root src

Or over the VIKE_CONFIG environment variable:

$ VIKE_CONFIG="{root:'src'}" vike dev

Both are equivalent to setting Vite's root setting:

// vite.config.js
 
export default {
  root: 'src'
}
// vite.config.ts
 
import type { UserConfig } from 'vite'
 
export default {
  root: 'src'
} satisfies UserConfig

Unlike most Vike settings, +root can't be defined inside a +config.js file (Vike emits a warning if you try): Vike needs to know the root directory before it can find your +config.js files. Set it over the CLI, the VIKE_CONFIG environment variable, vite.config.js, or Vike's API instead.

See also