CDN Deployment

Deploy built Vite assets to remote storage backends using fsspec.

The ViteDeployer class provides a robust deployment solution for syncing built assets to cloud storage providers like S3, GCS, Azure Blob Storage, and more.

Features

  • Deploy to any fsspec-compatible backend (S3, GCS, Azure, etc.)

  • Smart diffing: only uploads changed files

  • Optional orphaned file cleanup

  • Dry-run mode for testing

  • Progress callbacks for monitoring

  • Manifest-based file tracking

  • Content-Type header configuration

Available Classes

ViteDeployer

Main class for deploying Vite assets to remote storage.

FileInfo

Lightweight file metadata used for sync planning.

SyncPlan

Diff plan showing files to upload or delete.

SyncResult

Deployment result summary with uploaded/deleted file counts and sizes.

Available Functions

format_bytes

Human-friendly byte size formatting (e.g., “1.5 MB”).

Vite CDN deployment utilities.

Provides a deployer for publishing built Vite assets to any fsspec backend. DeployConfig is defined in litestar_vite.config and passed into ViteDeployer.

class litestar_vite.deploy.FileInfo[source]

Bases: object

Lightweight file metadata used for sync planning.

__init__(path: str, size: int, mtime: float) None
class litestar_vite.deploy.SyncPlan[source]

Bases: object

Diff plan for deployment.

__init__(to_upload: list[str], to_delete: list[str]) None
class litestar_vite.deploy.SyncResult[source]

Bases: object

Deployment result summary.

__init__(uploaded: list[str], deleted: list[str], uploaded_bytes: int, deleted_bytes: int, dry_run: bool) None
class litestar_vite.deploy.ViteDeployer[source]

Bases: object

Deploy built Vite assets to a remote fsspec backend.

__init__(*, bundle_dir: Path, manifest_name: str, deploy_config: DeployConfig, fs: Any | None = None, remote_path: str | None = None) None[source]
property fs: Any

Filesystem for deployment operations.

Returns:

The filesystem used for deployment operations.

collect_local_files() dict[str, FileInfo][source]

Collect local files to publish.

Returns:

Mapping of relative paths to file metadata.

collect_remote_files() dict[str, FileInfo][source]

Collect remote files from the target storage.

Returns:

Mapping of relative remote paths to file metadata.

static compute_diff(local: dict[str, FileInfo], remote: dict[str, FileInfo], delete_orphaned: bool) SyncPlan[source]

Compute which files to upload or delete.

Parameters:
  • local – Local files keyed by relative path.

  • remote – Remote files keyed by relative path.

  • delete_orphaned – Whether to remove remote-only files.

Returns:

SyncPlan listing upload and delete actions.

sync(*, dry_run: bool = False, on_progress: Callable[[str, str], None] | None = None) SyncResult[source]

Sync local bundle to remote storage.

Parameters:
  • dry_run – When True, compute the plan without uploading or deleting.

  • on_progress – Optional callback receiving an action and path for each step.

Returns:

SyncResult summarizing the deployment.

litestar_vite.deploy.format_bytes(size: int) str[source]

Human friendly byte formatting.

Returns:

The formatted byte size string.