Django 压缩器空白 CSS 输出文件

发布于 2024-12-27 23:46:29 字数 883 浏览 2 评论 0原文

当 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) 总是空的!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神经大条 2025-01-03 23:46:29

你是通过 npm 还是通过 ruby​​ gem 安装的?如果是后者,请尝试更新为:

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

请参阅此问题: https://github.com/jezdez /django_compressor/pull/177

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文