当 django 压缩 css 时,它会将输出保存到/static/CACHE/css/[filename].css 中的文件中,但是无论我尝试什么,css 文件总是空白!
在我的模板中...
{% compress css %}
<link rel='stylesheet' type='text/less' href='{{ STATIC_URL }}css/deals_for_you.less'/>
{% endcompress %}
我成功安装了 django_compressor、django_appconf 和 versiontools 我成功安装了 lessc (testecd) STATICFILES_FINDERS 已设置
COMPRESS_OFFLINE = True
COMPRESS_ENABLED = True
COMPRESS_OFFLINE_CONTEXT = {
'STATIC_URL': STATIC_URL,
}
COMPRESS_PRECOMPILERS = (
('text/less', 'lessc {infile} {outfile}'),
)
另外,当我运行时
python manage.py compress
它输出...
Found 'compress' tags in:
[/my/file/path]/index.html
Compressing... done
Compressed 1 block(s) from 1 template(s)
但是我得到的输出文件(位于/static/CACHE/css/d41d8cd98f00.css) 总是空的!
最佳答案
您是通过 npm 还是通过 ruby gem 安装的?如果是后者,请尝试更新为:
COMPRESS_PRECOMPILERS = (
('text/less', 'lessc {infile} > {outfile}'),
)
关于python - Django Compressor 空白 Css 输出文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8899913/