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.
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 ;)
发布评论
评论(2)
我们选择避免自动运行时 sass/compass 编译,而是在开发中简单地使用“compass --watch”并将 Sass 和生成的 CSS 提交到存储库。那么您的 Django 项目中根本不需要任何特殊的机制;您只需像平常一样处理 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:
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.
最好的选择是使用 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 ;)