Auto-detects your static files for minification, combination, and versioning. Like Django-Compressor for Flask.
Project description
Auto-detects your static files for minification, combination, and versioning. Like Django-Compressor for Flask.
Installation
pip install flask-static-compress
Usage
Just wrap your existing css/js with a compress block and Flask-Static-Compress handles the rest:
{% compress 'css' %} <link rel="stylesheet" type="text/sass" href="file.sass"> {% endcompress %} {% compress 'js' %} <script type="text/coffeescript" src="file.js"></script> {% endcompress %}
Also, initialize the extension inside your Flask app:
from flask_static_compress import FlaskStaticCompress app = Flask(__name__) compress = FlaskStaticCompress(app)
All static assets inside a compress block are compressed into a single file, and the html is updated to use the new file when rendering the template.
The type attribute is used to decide which compressor to use for the asset.
Use offline compression for improved performance.
Create custom compressors to support more types of static files.
Configuration
COMPRESSOR_ENABLED Default: True
COMPRESSOR_OFFLINE_COMPRESS Default: False
COMPRESSOR_FOLLOW_SYMLINKS Default: False
COMPRESSOR_DEBUG Default: False
COMPRESSOR_OUTPUT_DIR Default: app.static_folder
COMPRESSOR_STATIC_PREFIX Default: app.static_url_path
COMPRESSOR_CLASSES Default:
[ 'text/css': LessCompressor, 'text/coffeescript': CoffeeScriptCompressor, 'text/less': LessCompressor, 'text/javascript': JavaScriptCompressor, 'text/sass': SassCompressor, 'text/scss': SassCompressor, ]
Thanks to Jay Santos, creator of jac. Flask-Static-Compress is just a wrapper around jac!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for Flask-Static-Compress-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c284ba2b2b32c3633e1051ee382d2f6a413aa5bcf72e7ee07cc6c42232130bb |
|
MD5 | cf829c973e8166c72130150ed9ff2c34 |
|
BLAKE2b-256 | 5b679ef0d5a3b9b758d49744cfb03a20884a264ce568de5ce02e1a04a17b3773 |