Commands

litestar_vite.commands.to_json(value: Any) str[source]

Serialize JSON field values.

Parameters:

value – Any json serializable value.

Returns:

JSON string.

litestar_vite.commands.init_vite(app: Litestar, root_path: Path, resource_path: Path, asset_url: str, public_path: Path, bundle_path: Path, enable_ssr: bool, vite_port: int, hot_file: Path, litestar_port: int) None[source]

Initialize a new Vite project.

Parameters:
  • app – The Litestar application instance.

  • root_path – Root directory for the Vite project.

  • resource_path – Directory containing source files.

  • asset_url – Base URL for serving assets.

  • public_path – Directory for static files.

  • bundle_path – Output directory for built files.

  • enable_ssr – Enable server-side rendering.

  • vite_port – Port for Vite dev server.

  • hot_file – Path to hot reload manifest.

  • litestar_port – Port for Litestar server.

Raises:

MissingDependencyError – If required dependencies are not installed.

litestar_vite.commands.get_template(environment: Environment, name: str | Template, parent: str | None = None, globals: MutableMapping[str, Any] | None = None) Template[source]

Get a template from the Jinja environment.

Parameters:
  • environment – The Jinja jinja2.Environment.

  • name – Template name or jinja2.Template object.

  • parent – Parent template name.

  • globals – Global variables for the template.

Returns:

The jinja2.Template object.

Raises:

MissingDependencyError – If Jinja2 is not available.

litestar_vite.commands.execute_command(command_to_run: list[str], cwd: str | TypeAliasForwardRef('pathlib.Path') | None = None) CompletedProcess[bytes][source]

Run Vite in a subprocess.

Parameters:
  • command_to_run – The command to run.

  • cwd – The current working directory.

Returns:

The completed process.