django - 在 Heroku 上使用 Grunt 处理 Django 应用程序的静态文件

标签 django heroku gruntjs

当我们将 Django 应用程序部署到 Heroku 时,我们想使用 GruntJS ( http://gruntjs.com/ ),一个我们熟悉的包来缩小 JS 并将 LESS 编译成 CSS(除其他外)。有没有人想出一个聪明的做法呢?

我自己看了几个小时后什么也没找到。

最佳答案

尝试使用 django_compressorCOMPRESS_PRECOMPILERS设置。

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

模板:

{% compress css %}
<link type="text/less" rel="stylesheet" href="/static/css/styles.less" charset="utf-8">
<style type="text/less">
@color: #4D926F;

#header {
  color: @color;
}
</style>
{% endcompress %}

关于django - 在 Heroku 上使用 Grunt 处理 Django 应用程序的静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19642874/

相关文章:

django - 所引用的交易不符合发放信用的标准

python - django-userena 中的多个用户配置文件

python - 如何在Pycharm Windows 中解决 "django.db.utils.OperationalError: FATAL: password authentication failed for user "Oeloun-pc""?

ruby - 我怎样才能告诉 unicorn 理解 Heroku 的信号?

heroku - 项目无法更新 : Gateway rejected: fraud

security - 对heroku postgresql DB的访问只能仅限于它的heroku应用程序吗?

javascript - JSHint - ^ 'concise methods' 在 ES6 中可用

python - 使用 PIL 在 Django 中调整上传文件的大小

javascript - Gruntfile.js - 抛出错误 'Recursive process.nextTick detected"

deployment - 有什么好的grunt ftp插件吗?