From 2d5365d2a8814cd861a777ffa3fbd2a222fefc3f Mon Sep 17 00:00:00 2001 From: Jens Kadenbach Date: Thu, 12 Sep 2019 12:56:37 +0200 Subject: [PATCH] Compile scss files with django compressor --- compose/local/django/Dockerfile | 2 +- compose/production/django/Dockerfile | 2 +- config/settings/base.py | 3 +++ schickmacher/static/css/project.css | 13 ------------- .../static/{css/render.css => sass/render.scss} | 0 schickmacher/templates/base.html | 2 +- schickmacher/templates/renderer/rendered.html | 4 +++- 7 files changed, 9 insertions(+), 17 deletions(-) delete mode 100644 schickmacher/static/css/project.css rename schickmacher/static/{css/render.css => sass/render.scss} (100%) diff --git a/compose/local/django/Dockerfile b/compose/local/django/Dockerfile index bfad03a..9c1874c 100644 --- a/compose/local/django/Dockerfile +++ b/compose/local/django/Dockerfile @@ -16,7 +16,7 @@ RUN apk update \ && apk add postgresql-client \ # https://weasyprint.readthedocs.io/en/latest/install.html && apk add gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev \ - && apk add ttf-ubuntu-font-family + && apk add libsass sassc # Requirements are installed here to ensure they will be cached. COPY ./requirements /requirements diff --git a/compose/production/django/Dockerfile b/compose/production/django/Dockerfile index 6f337e6..c5a1728 100644 --- a/compose/production/django/Dockerfile +++ b/compose/production/django/Dockerfile @@ -13,7 +13,7 @@ RUN apk update \ && apk add libffi-dev py-cffi \ # https://weasyprint.readthedocs.io/en/latest/install.html && apk add gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev \ - && apk add ttf-ubuntu-font-family + && apk add libsass sassc RUN addgroup -S django \ && adduser -S -G django django diff --git a/config/settings/base.py b/config/settings/base.py index c370030..9cb2cf2 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -265,5 +265,8 @@ SOCIALACCOUNT_ADAPTER = "schickmacher.users.adapters.SocialAccountAdapter" # https://django-compressor.readthedocs.io/en/latest/quickstart/#installation INSTALLED_APPS += ["compressor"] STATICFILES_FINDERS += ["compressor.finders.CompressorFinder"] +COMPRESS_PRECOMPILERS = ( + ('text/x-scss', 'sassc {infile} {outfile}'), +) # Your stuff... # ------------------------------------------------------------------------------ diff --git a/schickmacher/static/css/project.css b/schickmacher/static/css/project.css deleted file mode 100644 index f1d543d..0000000 --- a/schickmacher/static/css/project.css +++ /dev/null @@ -1,13 +0,0 @@ -/* These styles are generated from project.scss. */ - -.alert-debug { - color: black; - background-color: white; - border-color: #d6e9c6; -} - -.alert-error { - color: #b94a48; - background-color: #f2dede; - border-color: #eed3d7; -} diff --git a/schickmacher/static/css/render.css b/schickmacher/static/sass/render.scss similarity index 100% rename from schickmacher/static/css/render.css rename to schickmacher/static/sass/render.scss diff --git a/schickmacher/templates/base.html b/schickmacher/templates/base.html index 08c8cbf..3e64059 100644 --- a/schickmacher/templates/base.html +++ b/schickmacher/templates/base.html @@ -25,7 +25,7 @@ {% compress css %} - + {% endcompress %} {% endblock %} diff --git a/schickmacher/templates/renderer/rendered.html b/schickmacher/templates/renderer/rendered.html index 079b80c..771fdde 100644 --- a/schickmacher/templates/renderer/rendered.html +++ b/schickmacher/templates/renderer/rendered.html @@ -3,7 +3,9 @@ {{ title }} - + {% compress css %} + + {% endcompress %}