Lean Django + Vite integration with rolling-deploy-safe manifest caching.
Project description
django-vite-rolling
A lean Django + Vite integration with rolling-deploy-safe manifest caching.
Roughly 100 lines of code. No React Refresh, no polyfills, no legacy bundle handling — just {% vite_scripts %}, {% vite_styles %}, and a management command that keeps Vite manifest caches consistent across rolling deploys.
Why this exists
Most Django + Vite integrations cache one manifest globally. On a rolling deploy, both the old and new app versions can serve requests simultaneously, each needing their own manifest. This package caches manifests under versioned Redis keys (vite_manifest:<RELEASE_VERSION>) and provides a management command to prune stale versions during deploys.
If you don't need versioned/rolling-deploy support, you probably want django-vite instead.
Install
pip install django-vite-rolling
Add to INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"django_vite_rolling",
]
Requires django-redis configured as your default cache backend.
Configure
VITE = {
"manifest_path": BASE_DIR / "static" / ".vite" / "manifest.json",
"cache": not DEBUG,
}
All settings
| Key | Default | Description |
|---|---|---|
manifest_path |
(required) | Path to Vite's manifest.json |
cache |
True |
Whether to cache the loaded manifest in Redis (set False in dev) |
cache_key_prefix |
"vite_manifest" |
Redis key prefix; full key is <prefix>:<RELEASE_VERSION> |
dev_server_host |
None |
Dev server host. None → derive from request Host header (fallback localhost) |
dev_server_port |
3001 |
Dev server port |
dev_server_static_path |
"/static" |
Path prefix Vite serves from |
versions_to_keep |
5 |
How many recent release versions to retain manifests for |
version_setting |
"RELEASE_VERSION" |
Name of the Django setting holding the current release identifier |
versions_redis_key |
"recent-manifest-versions" |
Redis list key tracking recent versions |
redis_alias |
"default" |
django-redis alias to use |
Usage
In your base template:
{% load vite %}
<!DOCTYPE html>
<html>
<head>
{% vite_styles "src/main.ts" %}
</head>
<body>
{% vite_scripts "src/main.ts" %}
</body>
</html>
In DEBUG mode the tags inject Vite's HMR client and module URLs pointing at the dev server. In production they resolve the named entries through the manifest, including recursively-imported chunks and their CSS.
Post-deploy
Run after each deploy (e.g., in a release-phase / post-deploy hook):
python manage.py refresh_vite_manifest
This:
- Records
RELEASE_VERSIONin a Redis list of recent versions (truncated toversions_to_keep). - Scans for
vite_manifest:*keys whose suffix is not in the recent list and deletes them. - Loads the current manifest and caches it under
vite_manifest:<RELEASE_VERSION>.
If RELEASE_VERSION is empty, the command caches the manifest under the bare prefix and skips cleanup.
Development
pip install -e ".[test]"
pytest
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_vite_rolling-0.1.0.tar.gz.
File metadata
- Download URL: django_vite_rolling-0.1.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12bec256fbf85ea097b1eeaead48061c43f64b43d771817e2ac12d9ddf83f08d
|
|
| MD5 |
16b780f82f73bdc20c8ad8dea35e7122
|
|
| BLAKE2b-256 |
402c055d6445e75c4d54b1b0652c3f0bd08013c3bb0901bb305f789ea56dc04f
|
Provenance
The following attestation bundles were made for django_vite_rolling-0.1.0.tar.gz:
Publisher:
release.yml on wedgworth/django-vite-rolling
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_vite_rolling-0.1.0.tar.gz -
Subject digest:
12bec256fbf85ea097b1eeaead48061c43f64b43d771817e2ac12d9ddf83f08d - Sigstore transparency entry: 1549801801
- Sigstore integration time:
-
Permalink:
wedgworth/django-vite-rolling@18d980832a55dbc344c5bf6d505cc5ea0db65211 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wedgworth
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@18d980832a55dbc344c5bf6d505cc5ea0db65211 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_vite_rolling-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_vite_rolling-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a6110756aaac43526efdac296147eee8fa68a9abf61d1a8642d0e8f662527fc
|
|
| MD5 |
8f2bb57d5d7ebad82ea199a971a721b4
|
|
| BLAKE2b-256 |
ea034796d5c925e937d71b4cb46b69cfad1d04c5a50b72e206a2f910eb4e779e
|
Provenance
The following attestation bundles were made for django_vite_rolling-0.1.0-py3-none-any.whl:
Publisher:
release.yml on wedgworth/django-vite-rolling
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_vite_rolling-0.1.0-py3-none-any.whl -
Subject digest:
5a6110756aaac43526efdac296147eee8fa68a9abf61d1a8642d0e8f662527fc - Sigstore transparency entry: 1549801846
- Sigstore integration time:
-
Permalink:
wedgworth/django-vite-rolling@18d980832a55dbc344c5bf6d505cc5ea0db65211 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wedgworth
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@18d980832a55dbc344c5bf6d505cc5ea0db65211 -
Trigger Event:
push
-
Statement type: