new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vite · Guide · all subjects

cli

20 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

vite dev server start command

The `vite` command starts the Vite dev server in the current directory. `vite dev` and `vite serve` are aliases for `vite`. Usage: `vite [root]`

vite dev server CLI options

The dev server CLI supports these options: --host [host] (specify hostname, string), --port <port> (specify port, number), --open [path] (open browser on startup, boolean | string), --cors (enable CORS, boolean), --strictPort (exit if specified port is already in use, boolean), --force (force optimizer to ignore cache and re-bundle, boolean), -c/--config <file> (use specified config file, string), --base <path> (public base path, default: /, string), -l/--logLevel <level> (info | warn | error | silent, string), --clearScreen (allow/disable clear screen when logging, boolean), --configLoader <loader> (bundle | runner experimental | native experimental, default: bundle), --profile (start built-in Node.js inspector), -d/--debug [feat] (show debug logs, string | boolean), -f/--filter <filter> (filter debug logs, string), -m/--mode <mode> (set env mode, string), -h/--help (display available CLI options), -v/--version (display version number).

vite build command

The `vite build` command builds for production. Usage: `vite build [root]`

vite build CLI options

The build command CLI supports these options: --target <target> (transpile target, default: "baseline-widely-available", string), --outDir <dir> (output directory, default: dist, string), --assetsDir <dir> (directory under outDir to place assets in, default: "assets", string), --assetsInlineLimit <number> (static asset base64 inline threshold in bytes, default: 4096, number), --ssr [entry] (build specified entry for server-side rendering, string), --sourcemap [output] (output source maps for build, default: false, boolean | "inline" | "hidden"), --minify [minifier] (enable/disable minification or specify minifier to use, default: "oxc", boolean | "oxc" | "terser" | "esbuild"), --manifest [name] (emit build manifest json, boolean | string), --ssrManifest [name] (emit ssr manifest json, boolean | string), --emptyOutDir (force empty outDir when it's outside of root, boolean), -w/--watch (rebuilds when modules have changed on disk, boolean), -c/--config <file> (use specified config file, string), --base <path> (public base path, default: /, string), -l/--logLevel <level> (Info | warn | error | silent, string), --clearScreen (allow/disable clear screen when logging, boolean), --configLoader <loader> (bundle | runner experimental | native experimental, default: bundle), --profile (start built-in Node.js inspector), -d/--debug [feat] (show debug logs, string | boolean), -f/--filter <filter> (filter debug logs, string), -m/--mode <mode> (set env mode, string), -h/--help (display available CLI options), --app (build all environments, same as builder: {}, boolean, experimental).

vite optimize command deprecated

The `vite optimize` command pre-bundles dependencies, but it is deprecated because the pre-bundle process runs automatically and does not need to be called.

vite preview command

The `vite preview` command locally previews the production build. It should not be used as a production server as it's not designed for it. The command starts a server in the build directory (by default `dist`). Run `vite build` beforehand to ensure that the build directory is up-to-date. Depending on the project's configured appType, it makes use of certain middleware.

vite preview CLI options

The preview command CLI supports these options: --host [host] (specify hostname, string), --port <port> (specify port, number), --strictPort (exit if specified port is already in use, boolean), --open [path] (open browser on startup, boolean | string), --outDir <dir> (output directory, default: dist, string), -c/--config <file> (use specified config file, string), --base <path> (public base path, default: /, string), -l/--logLevel <level> (Info | warn | error | silent, string), --clearScreen (allow/disable clear screen when logging, boolean), --configLoader <loader> (bundle | runner experimental | native experimental, default: bundle), -d/--debug [feat] (show debug logs, string | boolean), -f/--filter <filter> (filter debug logs, string), -m/--mode <mode> (set env mode, string), -h/--help (display available CLI options).

Specifying alternative root directory

Running 'vite serve some/sub/dir' starts the dev server using a specified subdirectory as root. When the root is changed, the vite.config.js file must be moved to the new root directory since Vite resolves its config file inside the project root.

Default npm scripts in scaffolded Vite project

A scaffolded Vite project includes three default npm scripts: 'dev' which starts the dev server (aliases: 'vite dev', 'vite serve'), 'build' which builds for production, and 'preview' which locally previews the production build.

vite preview command purpose and port

The `vite preview` command boots up a local static web server that serves files from `dist` at `http://localhost:4173` by default. It is intended for previewing the build locally and is not meant as a production server. The port can be configured by passing the `--port` flag as an argument.

npm scripts for build and preview

Typical npm scripts for Vite projects are: `"build": "vite build"` to build the app, and `"preview": "vite preview"` to test the built app locally.

Ampersand in project path breaks npm on Windows

The path to a project folder that includes the ampersand character (&) does not work with npm on Windows due to an issue in npm/cmd-shim. To fix this, either switch to another package manager like pnpm or yarn, or remove the & character from the project path.

npm create vite command syntax

To scaffold a Vite project with npm 7+, use the command `npm create vite@latest my-vue-app -- --template vue`. The extra double-dash is required to pass the template option.

yarn create vite command syntax

To scaffold a Vite project with yarn, use the command `yarn create vite my-vue-app --template vue`.

pnpm create vite command syntax

To scaffold a Vite project with pnpm, use the command `pnpm create vite my-vue-app --template vue`.

Bun create vite command syntax

To scaffold a Vite project with Bun, use the command `bun create vite my-vue-app --template vue`.

Deno create vite command syntax

To scaffold a Vite project with Deno, use the command `deno init --npm vite my-vue-app --template vue`.

Supported Vite template presets

The currently supported template presets are: vanilla, vanilla-ts, vue, vue-ts, react, react-compiler, react-ts, react-compiler-ts, preact, preact-ts, lit, lit-ts, svelte, svelte-ts, solid, solid-ts, qwik, qwik-ts.

Using dot notation for project name in create-vite

You can use `.` as the project name when running create-vite to scaffold the project in the current directory.

Vite dev server default port

The Vite dev server runs on port 5173 by default when running npm run dev.

Give your agent this brain