2017-08-12 119 views
0

Django static precompiler似乎没有为我工作scss文件。我已经选中,如果我已经安装了编译器和我的Django的设置是如下Django静态预编译器不编译文件?

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" 

和我打电话从Django的模板相同如下

{% 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> 

有没有任何错误。输出结果与scss文件相同,没有进行编辑。有人能指出我在做什么错了吗?或者一些其他办法,支持编译scss以及coffee脚本

+0

你有DEBUG设置为true ?有些预编译器在这种情况下不起作用,不知道这个tbh。 – marcinowski

+0

我试着用'DEBUG'中的两个选项 – georoot

回答

0

默认情况下,汇编应在运行时 compile过滤服务模板来完成。

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

如果您使用不同的存储渲染

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

STATIC_PRECOMPILER_DISABLE_AUTO_COMPILE是以前collectstatic

True编译使用compilestatic验证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", 
    }), 
)