Usage:

  • $ vike dev Start development server.
  • $ vike build Build for production.
  • $ vike preview Start preview server using production build (only works for SSG apps).
  • $ vike prerender Pre-render pages (only needed when prerender.disableAutoRun is true).
  • $ vike -v Print Vike's installed version.

Vike settings

CLI options

You can pass any Vike setting as CLI option, for example:

# Make development server available over LAN and public addresses
$ vike dev --host
 
# Change port
$ vike preview --port 80
 
# Change mode
$ vike build --mode staging
 
# Change pre-render settings
$ vike build --prerender "{parallel:4,noExtraDir:true}"

These are all Vike settings: +host / +port / +mode / +prerender. (Vike aliases some Vite settings for convenience.)

The CLI option value syntax is JavaScript-like, see JSON5 syntax.

VIKE_CONFIG environment variable

You can also use the VIKE_CONFIG environment variable, for example:

# Make development server available over LAN and public addresses
$ VIKE_CONFIG="{host:true}" vike dev
 
# Also when running Vike's CLI over a package.json script
$ VIKE_CONFIG="{prerender:{parallel:4,noExtraDir:true}}" npm run build

The VIKE_CONFIG value syntax is JavaScript-like, see JSON5 syntax.

Vite settings

CLI options

The following Vite CLI options are supported:

  • --host
  • --mode
  • --port

These are actually all Vike settings, which alias Vite settings. See: +host / +port / +mode.

For other Vite settings, use vite.config.js or VITE_CONFIG.

Reach out if you believe some other Vite setting should also be added the list of CLI options.

VITE_CONFIG environment variable

You can use the VITE_CONFIG environment variable to pass any Vite setting, for example:

# Set Vite's server.host setting to true
$ VITE_CONFIG="{server:{host:true}}" vike dev
 
# Also when running Vike's CLI over a package.json script
$ VITE_CONFIG="{build:{outDir:'build'}}" npm run build
 
# Also when running Vike's CLI over a package.json script
$ VITE_CONFIG="{mode:'staging'}" npm run preview

The VITE_CONFIG value syntax is JavaScript-like, see JSON5 syntax.

JSON5 syntax

You can set the value of CLI options, VITE_CONFIG, and VIKE_CONFIG using JavaScript-like syntax, JSON syntax, or JSON5 syntax. (Vike uses JSON5 to parse the values.)

See also