sunlightlabs / django-mediasync

Toolkit to simplify static media development and deployment.
BSD 3-Clause "New" or "Revised" License
174 stars 30 forks source link

Support for SASS (and other CSS preprocessors) #22

Open bryanveloso opened 13 years ago

bryanveloso commented 13 years ago

django-css handles this quite well by having a COMPILER_FORMATS setting that points to the binary of the preprocessor you want to use.

COMPILER_FORMATS = {
    '.sass': {
        'binary_path':'sass',
        'arguments': '*.sass *.css'
    }
}

It then tries to find stylesheets with those extensions (usually within {% compress %} blocks).

There are many ways I think CSS preprocessors would fit within this project, one of them being to allow SASS to be used only for "development mode" and when the management command is used, process them and throw them on the server. django-css currently compresses everything that falls in between the {% compress %} block and then caches the link to the static file, even when working with CDNs.

Really, I just want to use SASS. :)

jcarbaugh commented 13 years ago

Hey there! It's taken me a while to get around to this. I've spoken with various people that use SASS on how they would see it fitting into mediasync. I just pushed a feature that, I believe, reflects their usage fairly well.

mediasync now has a pre_sync signal that is sent and a method that can be connected to it to run the SASS command on any scss and sass file in STATIC_ROOT. That should compile everything when the syncmedia management command is called. I'm not going to try to do anything special while developing since the sass --watch command should take care of that. It's all documented in the README under Signals.

Again, I don't use SASS myself, so I'm not sure if this is the best approach. If you or anyone else could try it and give feedback, it'd be much appreciated. I'll leave this issue open until I hear feedback on actual usage.