Django Static Precompiler not compiling files?

1k views Asked by At

Django static precompiler does not seem to be working with scss files for me. I already checked if i had the compiler installed and my settings for django are are follows

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'static_precompiler',
    'cms',
]

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'static_precompiler.finders.StaticPrecompilerFinder',
)

STATIC_URL = '/static/'
STATIC_ROOT = "static"

and i am calling the same from django template as follows

{% load compile_static %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Spacemailer</title>
    {% block seo %}
    {% endblock %}
    <link rel="stylesheet" href="{% static 'style/main.scss' | compile %}" type="text/css" media="all" />
</head>
    <body>
        {% block body %}
        {% endblock %}
    </body>
</html>

There are no errors whatsoever. The output is the same scss file with no compilations being made. Can someone point out what am i doing wrong with the same ? or some alternatives that will support compiling scss as well as coffee scripts

1

There are 1 answers

0
jackotonye On

By default the compilation should be done at run time serving the template with compilefilter.

{% static "js/alert.es6"|compile %}

Renders

<script type="application/javascript" src="/static/COMPILED/js/alert.js"></script>

If your using a different storage and STATIC_PRECOMPILER_DISABLE_AUTO_COMPILE is True compile using compilestatic before collectstatic

Verify the Compiler configuration

STATIC_PRECOMPILER_COMPILERS = (
       ('static_precompiler.compilers.SCSS', {
        "executable": "/usr/bin/sass",
        "sourcemap_enabled": True,
        "compass_enabled": True,
        "load_paths": ["/path"],
        "precision": 8,
        "output_style": "compressed",
    }),
)