【问题标题】:Issue compressing sass with django_compressor使用 django 压缩器压缩 sass 的问题
【发布时间】:2014-10-24 16:10:28
【问题描述】:

我在使用 django_compressorsassDjango 集成时遇到问题

以下是导致的错误:

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 &lt;foo&gt; }},但它返回相同的错误。我知道要包含变量,您需要使用COMPRESS_OFFLINE_CONTEXT,但不知道如何使用。

【问题讨论】:

    标签: css django sass django-compressor


    【解决方案1】:

    这可能是由于您的 sass 文件中的语法错误。当这是一个单独的文件时,您确定所有的 mixin 都可以访问吗?您还可以将要压缩的文件中的大部分代码注释掉,以查看一个简单的最小文件是否正确压缩。

    【讨论】:

      猜你喜欢
      • 2017-01-02
      • 2011-09-01
      • 2012-09-25
      • 2017-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多