compass watch internals and error logs
This morning I was looking for how compass internally works and didn't find a lot of information about the internals, so I'll explain some of the basics that satiated my curiosity.
When you initialize compass in a project by doing
$> compass init rails project
You will see that when you change your scss files, your css files are automatically refreshed. Both sass and compass have a watch utility, and I thought one of these was fired on background to perform the update when necessary. But looking at the running processes I could not find the one that was doing it.
In fact, this action is performed by a third mechanism: sass includes a rack middleware to do it in every petition: http://sass-lang.com/docs/yardoc/Sass/Plugin/Rack.html which in turn is initialized by Compass.
You can also see the Compass watch implementation as a File System State Monitor to verify that is "simply" an independent process, and that does not play with your requests.
In fact, everything started because, due to an error in my scss file, nothing was being rendered properly. As a Compass noob I was expecting the compile error to be shown in my rails log, or even in a separate error log file. But there was no trace of the error, and I couldn't find a reference of where it should be. Well, Firebug was telling me that the generated css had no rules, but that doesn't mean it's empty! I finally "discovered" that Sass puts your trace in the generated css, as a comment.
Comments [0]