Django Compressor Blank Css Output File

2019-05-04 05:15发布

When django compresses css it saves the output to a file in /static/CACHE/css/[filename].css, however no matter what I try, the css file keeps coming out blank!

In my template...

{% compress css %}
<link rel='stylesheet' type='text/less' href='{{ STATIC_URL }}css/deals_for_you.less'/>
{% endcompress %}

I installed django_compressor, django_appconf, and versiontools successfully I installed lessc successfully (testecd) STATICFILES_FINDERS are set

COMPRESS_OFFLINE = True
COMPRESS_ENABLED = True
COMPRESS_OFFLINE_CONTEXT = {
    'STATIC_URL': STATIC_URL,
}
COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} {outfile}'),
)

Also, when I run

python manage.py compress

It outputs...

Found 'compress' tags in:
    [/my/file/path]/index.html
Compressing... done
Compressed 1 block(s) from 1 template(s)

But the output file that I get (at /static/CACHE/css/d41d8cd98f00.css) is always empty!

1条回答
乱世女痞
2楼-- · 2019-05-04 05:42

Did you install via npm or via a ruby gem? If the latter, try updating to:

COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} > {outfile}'),
)

See the issue on this: https://github.com/jezdez/django_compressor/pull/177

查看更多
登录 后发表回答