> ## Documentation Index
> Fetch the complete documentation index at: https://stars-components.js.org/llms.txt
> Use this file to discover all available pages before exploring further.

# @wolfstar/vite-server

> Vite build and watch integration that the stars CLI loads on demand behind the experimental.enableVite flag when build.tool is vite.

```bash npm theme={"system"}
npm install @wolfstar/vite-server vite
```

```bash pnpm theme={"system"}
pnpm add @wolfstar/vite-server vite
```

```bash yarn theme={"system"}
yarn add @wolfstar/vite-server vite
```

```bash bun theme={"system"}
bun add @wolfstar/vite-server vite
```

> [card] [npm](https://npmx.dev/package/@wolfstar/vite-server)

> [card] [Source](https://github.com/wolfstar-project/stars-components/tree/main/packages/vite-server)

## Description

`@wolfstar/vite-server` is the Vite build and watch integration for Stars projects. The
[`stars` CLI](https://stars-components.js.org/documentation/packages/cli) loads it on demand when `build.tool` resolves to `'vite'`, so existing
`stars.config` options and CLI commands are unchanged. Install `vite` in the consuming project; the integration
uses the project's own versions and Vite configuration.

## When to use it

Enable the integration through `stars.config.ts` — the CLI handles loading and lifecycle for you:

```typescript theme={"system"}
import { defineConfig } from '@wolfstar/http-framework/config';

export default defineConfig({
	build: { tool: 'vite' },
	experimental: {
		enableVite: true
	}
});
```

Depend on this package directly only when you are embedding the builder into your own tooling. In every other case
the CLI resolves and loads it for you.

## Programmatic usage

The package exports `ViteBuilder`. Pass a resolved `StarsConfig` and a `BuilderContext` from
[`@wolfstar/schema`](https://stars-components.js.org/documentation/packages/schema):

```typescript theme={"system"}
import { ViteBuilder } from '@wolfstar/vite-server';
import type { BuilderContext, ResolvedStarsConfig } from '@wolfstar/schema';

export async function build(config: ResolvedStarsConfig, context: BuilderContext) {
	const builder = new ViteBuilder(config, context);
	try {
		return await builder.build();
	} finally {
		await builder.close();
	}
}
```

The host supplies `importFromProject` (project-relative dependency loading with diagnostics) and
`pluginRegistrations` (the entry transform that activates installed plugins). Since `0.2.2`, `pluginRegistrations`
only injects `<name>/register` for `@wolfstar/plugin-*` dependencies whose `exports` map defines `./register`, so
library plugins such as `@wolfstar/plugin-cache` no longer fail with `ERR_PACKAGE_PATH_NOT_EXPORTED`. This explicit boundary keeps the
integration independent of the CLI and framework runtimes.

`watch()` and `close()` implement the shared builder lifecycle. `start`, `success`, `failure`, and `log` events
expose build status.

Vite builds the application and uses its build watcher for rebuilds. Process supervision remains the responsibility
of the host CLI.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.