Skip to content
Snippets Groups Projects
Verified Commit 489780a6 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Compile CSS to media instead of static

This allows making the STATIC_ROOT read-only

Requires django-sass-processor 1.0
parent aeba232a
No related branches found
No related tags found
1 merge request!543Resolve "[Docker] Review handling of volumes"
......@@ -817,3 +817,7 @@ if _settings.get("storage.s3.enabled", False):
AWS_S3_GZIP = _settings.get("storage.s3.gzip", True)
AWS_S3_SIGNATURE_VERSION = _settings.get("storage.s3.signature_version", None)
AWS_S3_FILE_OVERWRITE = _settings.get("storage.s3.file_overwrite", False)
else:
DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage"
SASS_PROCESSOR_STORAGE = DEFAULT_FILE_STORAGE
"""Helpers for SASS/SCSS compilation."""
import os
from glob import glob
from django.conf import settings
from colour import web2hex
from sass import SassColor
from sass_processor.storage import SassFileStorage
from .core_helpers import get_site_preferences
......@@ -26,9 +22,8 @@ def get_preference(section: str, name: str) -> str:
def clean_scss(*args, **kwargs) -> None:
"""Unlink compiled CSS (i.e. cache invalidation)."""
for source_map in glob(os.path.join(settings.STATIC_ROOT, "*.css.map")):
try:
os.unlink(source_map)
except OSError:
# Ignore because old is better than nothing
pass # noqa
sass_storage = SassFileStorage()
__, files = sass_storage.listdir("")
for source_map in filter(lambda x: x.endswith(".css.map"), files):
sass_storage.delete(source_map)
......@@ -42,7 +42,7 @@ django-menu-generator-ng = "^1.2.3"
django-tables2 = "^2.1"
Pillow = "^8.0"
django-phonenumber-field = {version = "<5.1", extras = ["phonenumbers"]}
django-sass-processor = "^0.8"
django-sass-processor = "^1.0"
libsass = "^0.20.0"
colour = "^0.1.5"
dynaconf = {version = "^3.1", extras = ["yaml", "toml", "ini"]}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment