Plugin

litestar_vite.plugin.set_environment(config: ViteConfig) None[source]

Configure environment for easier integration

class litestar_vite.plugin.StaticFilesConfig[source]

Bases: object

StaticFilesConfig(after_request: ‘AfterRequestHookHandler | None’ = None, after_response: ‘AfterResponseHookHandler | None’ = None, before_request: ‘BeforeRequestHookHandler | None’ = None, cache_control: ‘CacheControlHeader | None’ = None, exception_handlers: ‘ExceptionHandlersMap | None’ = None, guards: ‘list[Guard] | None’ = None, middleware: ‘Sequence[Middleware] | None’ = None, opt: ‘dict[str, Any] | None’ = None, security: ‘Sequence[SecurityRequirement] | None’ = None, tags: ‘Sequence[str] | None’ = None)

__init__(after_request: AfterRequestHookHandler | None = None, after_response: AfterResponseHookHandler | None = None, before_request: BeforeRequestHookHandler | None = None, cache_control: CacheControlHeader | None = None, exception_handlers: ExceptionHandlersMap | None = None, guards: list[Guard] | None = None, middleware: Sequence[Middleware] | None = None, opt: dict[str, Any] | None = None, security: Sequence[SecurityRequirement] | None = None, tags: Sequence[str] | None = None) None
class litestar_vite.plugin.ViteProcess[source]

Bases: object

Manages the Vite process.

__init__() None[source]
start(command: list[str], cwd: Path | str | None) None[source]

Start the Vite process.

stop(timeout: float = 5.0) None[source]

Stop the Vite process.

class litestar_vite.plugin.VitePlugin[source]

Bases: InitPluginProtocol, CLIPlugin

Vite plugin.

__init__(config: ViteConfig | None = None, asset_loader: ViteAssetLoader | None = None, static_files_config: StaticFilesConfig | None = None) None[source]

Initialize Vite.

Parameters:
  • config – configuration to use for starting Vite. The default configuration will be used if it is not provided.

  • asset_loader – an initialized asset loader to use for rendering asset tags.

  • static_files_config – optional configuration dictionary for the static files router.

on_cli_init(cli: Group) None[source]

Called when the CLI is initialized.

This can be used to extend or override existing commands.

Parameters:

cli – The root click.Group of the Litestar CLI

Examples

from litestar import Litestar
from litestar.plugins import CLIPluginProtocol
from click import Group


class CLIPlugin(CLIPluginProtocol):
    def on_cli_init(self, cli: Group) -> None:
        @cli.command()
        def is_debug_mode(app: Litestar):
            print(app.debug)


app = Litestar(plugins=[CLIPlugin()])
on_app_init(app_config: AppConfig) AppConfig[source]

Configure application for use with Vite.

Parameters:

app_config – The AppConfig instance.

server_lifespan(app: Litestar) Iterator[None][source]

Manage Vite server process lifecycle.