Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best method for adding compass to a django project

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

like image 813
demet8 Avatar asked May 05 '11 15:05

demet8


2 Answers

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.

like image 128
Carl Meyer Avatar answered Sep 20 '22 18:09

Carl Meyer


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 ;)

like image 33
Thomas Avatar answered Sep 16 '22 18:09

Thomas