zco*_*y13 5 css python compression django
当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 %}
Run Code Online (Sandbox Code Playgroud)
我成功安装了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}'),
)
Run Code Online (Sandbox Code Playgroud)
还有,当我跑
python manage.py compress
Run Code Online (Sandbox Code Playgroud)
它输出......
Found 'compress' tags in:
[/my/file/path]/index.html
Compressing... done
Compressed 1 block(s) from 1 template(s)
Run Code Online (Sandbox Code Playgroud)
但是我得到的输出文件(在/static/CACHE/css/d41d8cd98f00.css)总是空的!
你是通过 npm 还是通过 ruby gem 安装的?如果是后者,请尝试更新为:
COMPRESS_PRECOMPILERS = (
('text/less', 'lessc {infile} > {outfile}'),
)
Run Code Online (Sandbox Code Playgroud)
请参阅此问题:https ://github.com/jezdez/django_compressor/pull/177