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: ‘Optional[AfterRequestHookHandler]’ = None, after_response: ‘Optional[AfterResponseHookHandler]’ = None, before_request: ‘Optional[BeforeRequestHookHandler]’ = None, cache_control: ‘Optional[CacheControlHeader]’ = None, exception_handlers: ‘Optional[ExceptionHandlersMap]’ = None, guards: ‘Optional[list[Guard]]’ = None, middleware: ‘Optional[Sequence[Middleware]]’ = None, opt: ‘Optional[dict[str, Any]]’ = None, security: ‘Optional[Sequence[SecurityRequirement]]’ = None, tags: ‘Optional[Sequence[str]]’ = 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.
- 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()])