【发布时间】:2014-10-24 16:10:28
【问题描述】:
我在使用 django_compressor 将 sass 与 Django 集成时遇到问题
以下是导致的错误:
UncompressableFileError at /
'sass/example.scss' isn't accessible via COMPRESS_URL ('static') and can't be compressed
从模板来看,这会导致上面的错误-
{% load compressor %}
{% compress css inline %}
<link rel="stylesheet" type="text/x-sass" href="sass/example.scss"/>
{% endcompress %}
有趣的是,如果我这样做内联 sass 样式,压缩会起作用,这让我想知道这个问题是否与我链接资源的方式有关。
内联作品 -
{% load compressor %}
{% compress css inline %}
<style type="text/x-sass">
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
background: red;
}
</style>
{% endcompress %}
这里似乎有什么问题?
这些是我的设置 -
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_URL = STATIC_URL
COMPRESS_ENABLED = True
COMPRESS_PRECOMPILERS = (
('text/coffeescript', 'coffee --compile --stdio'),
('text/x-sass', 'sass {infile} {outfile}'),
('text/x-scss', 'sass --scss {infile} {outfile}'),
)
我认为问题在于我不确定如何设置href 的值?我想使用{{ static <foo> }},但它返回相同的错误。我知道要包含变量,您需要使用COMPRESS_OFFLINE_CONTEXT,但不知道如何使用。
【问题讨论】:
标签: css django sass django-compressor