2016-06-21 76 views
0

我一直在努力讓Django識別我的SCSS文件(我可能會濫用SCSS/SASS/LESS術語......他們的關係混淆了我)。我正在使用django-libsasscompress,這兩者看起來非常直截了當。我的頁面給了我錯誤「資源解釋爲樣式表,但使用MIME類型application/octet-stream傳輸:」。它正在加載頁面,但沒有顯示我的樣式。Django項目不識別SCSS文件

我不確定人們需要看什麼。我的模板包括:

<link href="{% static 'css/blog.scss' %}" rel="stylesheet"> 

(這工作得很好,當它是CSS)

設置:

COMPRESS_PRECOMPILERS = (
    ('text/x-scss', 'django_libsass.SassCompiler'), 
) 

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder', 
    'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
    # other finders.. 
    'compressor.finders.CompressorFinder', 
) 

回答

1

嘗試增加type="text/x-scss"將連接單元與壓縮標籤一起:

{% compress css %} 
    <link href="{% static 'css/blog.scss' %}" rel="stylesheet" type="text/x-scss"> 
{% endcompress %} 

並確保在使用前加載壓縮標籤:

{% load compress %} 
+0

呃。咄。謝謝。 – thumbtackthief