将指南针添加到 django 项目的最佳方法

发布于 2024-11-05 10:21:19 字数 230 浏览 1 评论 0原文

compasssusyblueprint 到 django 项目中?

What's the preferred or best method for integrating compass with susy or blueprint into a django project?

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

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

发布评论

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

评论(2

娇妻 2024-11-12 10:21:19

我们选择避免​​自动运行时 sass/compass 编译,而是在开发中简单地使用“compass --watch”并将 Sass 和生成的 CSS 提交到存储库。那么您的 Django 项目中根本不需要任何特殊的机制;您只需像平常一样处理 CSS 文件即可。

这对我们来说有几个优点:

  • 从我们的部署和生产服务器基础设施中删除了整个额外的移动部件:不需要在我们的生产服务器上拥有完整的 Ruby 堆栈,加上 Sass、Compass 和任何其他所需的 gem。使生产服务器更简单是一件非常好的事情。此外,部署到纯 Python 托管也没有问题。
  • 由于 Compass 插件 gem 版本等方面的微小差异,开发人员与另一位开发人员之间或开发与生产之间不会出现神秘的微妙显示不一致。每个人看到的 CSS 都是一样的。开发人员的 Compass 环境之间的差异可以很快被捕获,因为它们会立即显示为生成的 CSS 的预提交差异中的意外更改。

当然,缺点是将生成的代码提交到存储库,这通常是不受欢迎的。不过,我们还没有看到因此造成的任何实际问题。没有人会想直接编辑生成的 CSS;我们都知道我们使用指南针。对于我们来说,优点绝对大于缺点 - 我们从未有过丝毫的诱惑去切换到像 django-css 这样的集成方法。

We've chosen to avoid automatic runtime sass/compass compilation, and instead simply use "compass --watch" in development and commit both Sass and the generated CSS to the repository. Then there is no special machinery at all required in your Django project; you just handle the CSS files as you normally would.

This has several advantages for us:

  • Removes an entire additional chunk of moving parts from our deployment and production server infrastructure: no need to have a full Ruby stack, plus Sass, Compass, and any other required gems on our production servers. Making production servers simpler is A Very Good Thing. Also, no issues deploying to pure-Python hosting.
  • No mysterious subtle display inconsistencies between one developer and another, or between development and production, because of minor differences in something like a Compass plugin gem version. Everyone sees the same CSS. Differences between developers' Compass environments are caught quickly, because they show up right away as unexpected changes in the pre-commit diff of the generated CSS.

The disadvantage, of course, is committing generated code to the repo, which is generally frowned upon. We haven't seen any actual problems as a result of this, though. Nobody is tempted to edit the generated CSS directly; we all know that we use Compass. The advantages definitely outweigh the disadvantages, for us - we've never had the slightest temptation to switch to an integrated approach like django-css.

独闯女儿国 2024-11-12 10:21:19

最好的选择是使用 django-css,它是 django-compressor 的一个分支,它还可以对 SASS 进行 css 编译。一旦你插入了它,你就可以像平常一样使用 compass、susy 和 blueprint,只要 django 检测到源文件的更新版本,它们就会被 django 编译。

编辑:如果您要在纯 python 主机(例如 ep.io)上部署,您将需要研究如何轻松地将它们构建到 smartCSS(纯 python SASS 和 SCSS 编译器)中

编辑 2:

此信息已过时。 django-compressor 现在是最好的选择,因为它内置了预处理设施,并且它也能够为您捆绑文件;)

Your best bet is to use django-css, a fork of django-compressor which also does css compilation of SASS. Once you have that plugged in, you can use compass, susy and blueprint as normal, and they will be compiled by django whenever it detects an updated version of the source files.

EDIT: If you are deploying on a pure python host such as ep.io, you will want to research how easily these build into cleverCSS (Pure python SASS&SCSS compiler)

EDIT 2:

This info has dated. django-compressor is now the best option as it has the preprocessing facilities built in, and it will be able to bundle up the files for you too ;)

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