Automatic compilation can be done using the sass --watch command, but this requires you to set it up every time you start working on a project. In Eclipse, I couldn't find an existing way to automate the compile process, so I wrote an ant build script to do it, and then set that as a Project Builder and set it to run on "Auto Build", meaning every time a change is saved.
1) The ant build script. Put this in a file called build.xml in the root of your project. It just says to run sass (/var/lib/gems/1.9.1/bin/sass) on the directory "scss" and output the result to the directory "css". Don't forget to update the path to your sass executable, as well as your css and scss directories.
Update: bare in mind you can add an <arg><srcfile/> <targetfile/> <fileset dir="scss" includes="*.scss"/> <mapper from="*.scss" to="*.css" type="glob"/>
2) Add it as a Project Builder: in the project properties, click Builders, then New, and select Ant Builder. Give it a name, and select the Buildfile (click Browse Workspace and navigate to your build.xml). Under Targets, click the Set Targets button next to Auto Build, and select sass and click OK. Finally, under Build Options, check "Specify working set of relevant resources" and click the button to specify only your scss directory - this ensures the build script will only be run when you change your Sass files.
Above ant target is not quite right. It should be:
ReplyDeleteLooks like there is a problem with the formatter!
ReplyDeleteThank you for spotting this - unfortunately the formatter is not accepting self-closing elements. I've now implemented a workaround (using HTML character codes for less-than and greater-than signs).
ReplyDeleteNeed some help with this. New to sass in general and have never used ant. I get this error when it executes the xml.
ReplyDeletesrcfile doesn't support the nested "targetfile" element.
Well I just found that my sass executable is nested a little more than yours on my system but that didn't help either.
ReplyDeleteWhat about adding a builder with sass executable and "--update scss css" option ? Did the trick for me
ReplyDelete