Enhanced ManifestStaticFilesStorage for Django with backported improvements
Project description
Django ManifestStaticFiles Enhanced
Enhanced ManifestStaticFilesStorage for Django.
AI tools were used for creation of this package
- Tool(s) used: Claude Code
- What it was used for: Used for building initial versions of all features and for initial versions of original tests.
Features
This package includes several improvements to Django's ManifestStaticFilesStorage:
- ticket_27929:
keep_original_filesoption to control whether original files are deleted after hashing - ticket_21080: CSS lexer for better URL parsing in CSS files
- ticket_34322: JsLex for ES module support in JavaScript files
- ticket_28200: Optimized storage to avoid unnecessary file operations for unchanged files
Compatibility
- Django: 4.2, 5.0, 5.1, 5.2
- Python: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
Installation
pip install django-manifeststaticfiles-enhanced
Usage
Basic Usage
Replace Django's default ManifestStaticFilesStorage with the enhanced version using the STORAGES setting:
# settings.py
STORAGES = {
"staticfiles": {
"BACKEND": "django_manifeststaticfiles_enhanced.storage.EnhancedManifestStaticFilesStorage",
},
}
Configuration Options
keep_original_files (ticket_27929)
Control whether original files are kept after hashing:
# settings.py - Keep original files (default)
STORAGES = {
"staticfiles": {
"BACKEND": "django_manifeststaticfiles_enhanced.storage.EnhancedManifestStaticFilesStorage",
"OPTIONS": {
"keep_original_files": True, # Default
},
},
}
# Or delete original files to save space
STORAGES = {
"staticfiles": {
"BACKEND": "django_manifeststaticfiles_enhanced.storage.EnhancedManifestStaticFilesStorage",
"OPTIONS": {
"keep_original_files": False,
},
},
}
JavaScript Module Support (ticket_34322)
Disable ES module import/export processing:
# settings.py
STORAGES = {
"staticfiles": {
"BACKEND": "django_manifeststaticfiles_enhanced.storage.EnhancedManifestStaticFilesStorage",
"OPTIONS": {
"support_js_module_import_aggregation": False,
},
},
}
Easy access to existing options
Disable manifest_strict
# settings.py
STORAGES = {
"staticfiles": {
"BACKEND": "django_manifeststaticfiles_enhanced.storage.EnhancedManifestStaticFilesStorage",
"OPTIONS": {
"manifest_strict": False,
},
},
}
Also available:
- max_post_process_passes
- manifest_name: change the name of the staticfiles.json file
Feature Details
CSS Processing Improvements (ticket_21080)
CSS URL processing uses a proper lexer instead of regex, providing:
- Ignores url's in comments
- More reliable URL extraction
- Wider @import support
File Operation Optimization (ticket_28200)
Reduces unnecessary file operations during collectstatic:
- Avoids recreating files that haven't changed
- Checks file existence before deletion
JavaScript Module Support (ticket_34322)
Enabled by default:
- Processes ES6 import/export statements
- Handles dynamic imports
- Updates module paths to hashed versions
Example JavaScript that gets processed:
// Before processing
import { Component } from './component.js';
export { utils } from './utils.js';
// After processing (with hashing)
import { Component } from './component.abc123.js';
export { utils } from './utils.def456.js';
Option to not move the origianl asset to your static folder (ticket_27929)
Control file cleanup behavior:
# Keep original files (default)
keep_original_files = True
# Results in: style.css + style.abc123.css
# Delete original files
keep_original_files = False
# Results in: style.abc123.css only
Running Tests
# Install development dependencies
pip install -e .[dev]
# Run tests
python runtests.py
# Or run specific test modules
python runtests.py tests.staticfiles_tests.test_storage
Migration from Django's ManifestStaticFilesStorage
This package is designed as a drop-in replacement:
- Install the package
- Update your
STORAGESsetting - Run
python manage.py collectstaticas usual
All existing functionality remains the same, with additional features available through configuration options.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the BSD 3-Clause License - the same license as Django.
Changelog
0.1.0 (Initial Release)
- Includes
keep_original_filesoption (ticket_27929) - Includes CSS lexer improvements (ticket_21080)
- Includes file operation optimizations (ticket_28200)
- Includes JavaScript module support (ticket_34322)
- Added comprehensive test suite
- Support for Django 4.2+
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_manifeststaticfiles_enhanced-0.1.0.tar.gz.
File metadata
- Download URL: django_manifeststaticfiles_enhanced-0.1.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dd9fdb6385ee1df6292d825f1a59079c06cb9ae67c05c52b44a4404b92d2ef5
|
|
| MD5 |
47ba2c13c49e50304f65c5796103b11f
|
|
| BLAKE2b-256 |
812a8d8e80234e2b9f7f9df16dd14fa0e2adea891946a0e56c980ed9ca0b62ba
|
Provenance
The following attestation bundles were made for django_manifeststaticfiles_enhanced-0.1.0.tar.gz:
Publisher:
pypi-release.yml on blighj/django-manifeststaticfiles-enhanced
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_manifeststaticfiles_enhanced-0.1.0.tar.gz -
Subject digest:
7dd9fdb6385ee1df6292d825f1a59079c06cb9ae67c05c52b44a4404b92d2ef5 - Sigstore transparency entry: 264764175
- Sigstore integration time:
-
Permalink:
blighj/django-manifeststaticfiles-enhanced@e8c10236a6cbf2ffbf3021b57099efcac220e582 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/blighj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@e8c10236a6cbf2ffbf3021b57099efcac220e582 -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_manifeststaticfiles_enhanced-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_manifeststaticfiles_enhanced-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac10c09c6dbbdff97b9c882fac98a30702a8451293d6da17a59d93d4d87ac848
|
|
| MD5 |
ef877ce6b8c0a83f325c63848d12f2ab
|
|
| BLAKE2b-256 |
4972e7f27fed180b18076d206aaa2f5fbb2a09ffd86c4aeab50acc1373652893
|
Provenance
The following attestation bundles were made for django_manifeststaticfiles_enhanced-0.1.0-py3-none-any.whl:
Publisher:
pypi-release.yml on blighj/django-manifeststaticfiles-enhanced
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_manifeststaticfiles_enhanced-0.1.0-py3-none-any.whl -
Subject digest:
ac10c09c6dbbdff97b9c882fac98a30702a8451293d6da17a59d93d4d87ac848 - Sigstore transparency entry: 264764178
- Sigstore integration time:
-
Permalink:
blighj/django-manifeststaticfiles-enhanced@e8c10236a6cbf2ffbf3021b57099efcac220e582 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/blighj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@e8c10236a6cbf2ffbf3021b57099efcac220e582 -
Trigger Event:
release
-
Statement type: