Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django and compass with multiple apps

I want to use Compass to simplify the task of writing CSS in my Django app. But I don't know how to configure it.

I see django-compressor has support for SASS, but in order to use Compass I needed to dump the _*.scss files into my workspace (Django 1.4) since that's the working directory when django-compressor runs scss commands.

Eric Meyer's approach sounds sensible (compile .scss files to .css during development and commit to SCM) but it's not obvious how I can use the SASS/Compass tools to compile .scss in multiple apps (both reusable and non-reusable) in a Django workspace.

I store static stylesheet files for each app in <app>/static/<app>/css/.

The issues I have are this:

  1. @import doesn't work across apps
  2. Putting _*.scss files in the workspace is unacceptable
  3. Running compass watch in the workspace fails with:

    Nothing to compile. If you're trying to start a new project, you have left off the directory argument.

  4. Using @include background(...) fails:

    Syntax error: Undefined operation: "-compass-list-size(compact(#cccccc, false, false, false, false, false, false, false, false, false)) gt 1"

like image 805
bradley.ayers Avatar asked Jun 12 '12 00:06

bradley.ayers


1 Answers

I've found it's much easier to essentially separate Django from Sass. You can still use them concurrently, but it might require another terminal window or so. In the end it's all about serving the compiled assets anyway.

I normally configure my project with a /src/ directory in the root, which is where I place my Sass files. I also set up a Compass project in that root directory with the compiled stylesheets going into /static/css/.

Obviously this can become problematic if you have a lot of applications within the project as you'd either want to create application directories within the root /static/ or create another Compass project in /

Normally, I use Grunt to compile my Sass/Compass files, so it's a bit more complicated, although easy to recreate.

Frank Wiles's post Ultimate Front End Development Setup is pretty close to how I setup my projects, although I skip using django-compressor as I feel adding middleware is unneeded, and obviously I use Grunt instead of Gulp.

like image 154
faustman Avatar answered Sep 21 '22 02:09

faustman