Skip to content

Commit

Permalink
feat: set vite path from hotfile
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin committed Dec 10, 2023
1 parent 7389298 commit c2f6d73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions litestar_vite/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ViteAssetLoader:
def __init__(self, config: ViteConfig) -> None:
self._config = config
self._manifest: dict[str, Any] = {}
self._hot_file: str | None = None
self._vite_base_path: str | None = None

@classmethod
def initialize_loader(cls, config: ViteConfig) -> ViteAssetLoader:
Expand Down Expand Up @@ -68,7 +68,7 @@ def parse_manifest(self) -> None:
self._config.bundle_dir / self._config.hot_file,
).exists():
with Path(self._config.bundle_dir / self._config.hot_file).open() as hot_file:
self._hot_file = hot_file.read()
self._vite_base_path = hot_file.read()

else:
with Path(self._config.bundle_dir / self._config.manifest_name).open() as manifest_file:
Expand Down Expand Up @@ -181,7 +181,7 @@ def _vite_server_url(self, path: str | None = None) -> str:
Returns:
str: Full URL to the asset.
"""
base_path = f"{self._config.protocol}://{self._config.host}:{self._config.port}"
base_path = self._vite_base_path or f"{self._config.protocol}://{self._config.host}:{self._config.port}"
return urljoin(
base_path,
urljoin(self._config.asset_url, path if path is not None else ""),
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ license = {text = "MIT"}
name = "litestar-vite"
readme = "README.md"
requires-python = ">=3.8"
version = "0.1.3"
version = "0.1.4"

[project.urls]
Changelog = "https://cofin.github.io/litestar-vite/latest/changelog"
Expand Down

0 comments on commit c2f6d73

Please sign in to comment.