Skip to main content

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:

  • vite_scripts emits one <script type="module"> per entry and a <link rel="modulepreload"> for each chunk the entries import, so the browser fetches them in parallel.
  • vite_styles emits a stylesheet link for the entries' CSS and the CSS of every imported chunk.

Script and preload URLs are STATIC_URL plus Vite's file name. They skip static(), because chunks import each other by Vite's file name: a storage that adds its own hash (ManifestStaticFilesStorage, whitenoise) would make the browser download and run each module twice. Keep Vite's default hashed file names ([name]-[hash].js) so these URLs change when the content does. Stylesheet URLs still go through static().

Post-deploy

Run after each deploy (e.g., in a release-phase / post-deploy hook):

python manage.py refresh_vite_manifest

This:

  1. Records RELEASE_VERSION in a Redis list of recent versions (truncated to versions_to_keep).
  2. Scans for vite_manifest:* keys whose suffix is not in the recent list and deletes them.
  3. 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

Metadata

Release files for django-vite-rolling 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-vite-rolling 0.2.0
File Size Uploaded Provenance Actions
django_vite_rolling-0.2.0.tar.gz 13.5 kB With provenance Details for django_vite_rolling-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-vite-rolling 0.2.0
File Interpreter ABI Platform Actions
django_vite_rolling-0.2.0-py3-none-any.whl Python 3 none any Details for django_vite_rolling-0.2.0-py3-none-any.whl

Total release size: 22.3 kB

Release files / django_vite_rolling-0.2.0.tar.gz

Download URL django_vite_rolling-0.2.0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
532fb17333f45ed738b28ef650457774ad38c060cb376bc83e86369c08a97063
BLAKE2b-256 checksum
How to use checksums
3bd53a20971a0a9ec46ffc7fe68dfdfaa843d97039b33a8ead3ea20ada23369d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / django_vite_rolling-0.2.0-py3-none-any.whl

Download URL django_vite_rolling-0.2.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57c76bfe70dcb4da5c3c80cf0ae7428910a4a019e3ca5ec4fdeb797daa7d9ae0
BLAKE2b-256 checksum
How to use checksums
243ade074240ddcc73019be785fae2543fa72ff0db18ee0217c3295bb9c31805
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Security for django-vite-rolling 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_vite_rolling-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page