Usage:
$ vike devStart development server.$ vike buildBuild for production.$ vike previewStart preview server using production build.$ vike prerenderPre-render pages (only needed whenprerender.disableAutoRunistrue).$ vike -vPrint Vike's version.
Can I use Vite's CLI instead?
Yes, you can — Vike has full-fledged support for third-party CLIs (Vite, Vitest, Storybook, ...).
That said, we generally recommend using Vike's CLI for better DX. For example, you can pass Vike-specific settings like
$ vike build --prerender falsewhich isn't supported by third-party CLIs.
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 --forceThese 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
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 buildYou can set
VIKE_CONFIGusing JavaScript(-like) syntax (see JSON5 syntax).
Vite settings
CLI options
Vike's CLI supports following Vite CLI options:
--host--mode--port--force
These are Vike settings that alias Vite settings (see
+host/+mode/+port/+force). Each Vike CLI option corresponds to a Vike setting.Reach out if you believe some other Vite settings should also be aliased.
For other Vite settings, use vite.config.js or VITE_CONFIG.
VITE_CONFIG
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 previewYou can set
VITE_CONFIGusing 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'}is valid JSON5 (it isn't validJSON). - Extra JSON5 features
For example comments — the following is valid JSON5 (it isn't valid
JSON):// Some comment { "someProp": "someVal" }