Config

class litestar_vite.config.ViteConfig[source]

Bases: object

Configuration for ViteJS support.

To enable Vite integration, pass an instance of this class to the Litestar constructor using the ‘plugins’ key.

bundle_dir: Path | str = 'public'

Location of the compiled assets from Vite.

The manifest file will also be found here.

resource_dir: Path | str = 'resources'

The directory where all typescript/javascript source are written.

In a standalone Vue or React application, this would be equivalent to the ./src directory.

public_dir: Path | str = 'public'

The optional public directory Vite serves assets from.

In a standalone Vue or React application, this would be equivalent to the ./public directory.

manifest_name: str = 'manifest.json'

Name of the manifest file.

hot_file: str = 'hot'

Name of the hot file.

This file contains a single line containing the host, protocol, and port the Vite server is running.

hot_reload: bool

Enable HMR for Vite development server.

ssr_enabled: bool = False

Enable SSR.

ssr_output_dir: Path | str | None = None

SSR Output path

root_dir: Path | str | None = None

The is the base path to your application.

In a standalone Vue or React application, this would be equivalent to the top-level project folder containing the ./src directory.

is_react: bool = False

Enable React components.

asset_url: str

Base URL to generate for static asset references.

This URL will be prepended to anything generated from Vite.

host: str

Default host to use for Vite server.

__init__(bundle_dir: ~pathlib.Path | str = 'public', resource_dir: ~pathlib.Path | str = 'resources', public_dir: ~pathlib.Path | str = 'public', manifest_name: str = 'manifest.json', hot_file: str = 'hot', hot_reload: bool = <factory>, ssr_enabled: bool = False, ssr_output_dir: ~pathlib.Path | str | None = None, root_dir: ~pathlib.Path | str | None = None, is_react: bool = False, asset_url: str = <factory>, host: str = <factory>, protocol: str = 'http', port: int = <factory>, run_command: list[str] = <factory>, build_watch_command: list[str] = <factory>, build_command: list[str] = <factory>, install_command: list[str] = <factory>, use_server_lifespan: bool = <factory>, dev_mode: bool = <factory>, detect_nodeenv: bool = True, set_environment: bool = True, set_static_folders: bool = True) None
protocol: str = 'http'

Protocol to use for communication

port: int

Default port to use for Vite server.

run_command: list[str]

Default command to use for running Vite.

build_watch_command: list[str]

Default command to use for dev building with Vite.

build_command: list[str]

Default command to use for building with Vite.

install_command: list[str]

Default command to use for installing Vite.

use_server_lifespan: bool

Utilize the server lifespan hook to run Vite.

dev_mode: bool

When True, Vite will run with HMR or watch build

detect_nodeenv: bool = True

When True, The initializer will install and configure nodeenv if present

set_environment: bool = True

When True, configuration in this class will be set into environment variables.

This can be useful to ensure Vite always uses the configuration supplied to the plugin

set_static_folders: bool = True

When True, Litestar will automatically serve assets at the ASSET_URL path.

__post_init__() None[source]

Ensure that directory is set if engine is a class.