Usage:
$ vike dev
Start development server.$ vike build
Build for production.$ vike preview
Start preview server using production build.$ vike prerender
Pre-render pages (only needed whenprerender.disableAutoRun
istrue
).$ vike -v
Print Vike's installed version.
Vike settings
CLI options
You can pass any Vike setting to the CLI, 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}"
# Disable Vite's cache
$ vike dev --force
These are all Vike settings:
+host
/+port
/+mode
/+prerender
/+force
. (Note that Vike aliases some Vite settings for convenience, see Vite settings.)
You can set values using JavaScript(-like) syntax (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
You can set
VIKE_CONFIG
using JavaScript(-like) syntax (see JSON5 syntax).
Vite settings
CLI options
Vike's CLI supports following Vite CLI options:
--host
--mode
--port
--force
These are actually Vike settings, which alias Vite settings. (See
+host
/+mode
/+port
/+force
.) In other words: each Vike CLI option corresponds to a Vike setting.Reach out if you believe there are other Vite settings that should also be aliased.
For other Vite settings, use vite.config.js
or VITE_CONFIG
.
VITE_CONFIG
environment variable
You can use the VITE_CONFIG
environment variable to pass Vite settings, 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
You can set
VITE_CONFIG
using JavaScript(-like) syntax (see JSON5 syntax).
JSON5 syntax
Vike uses JSON5 to parse the values of Vike's CLI options and the values of the environment variables VITE_CONFIG
and VIKE_CONFIG
.
It's a JSON extension that supports:
- Standard JSON syntax
- JavaScript-like syntax
For example
{someProp:'someVal'}
, which isn't validJSON
, is valid JSON5. - Extra JSON5 features
For example comments — the following is valid JSON5 (it isn't valid
JSON
):// Some comment { "someProp": "someVal" }