Eclipse plugin to automatically compile Sass files

jackocnr picture jackocnr · Feb 24, 2012 · Viewed 27k times · Source

I'm currently using the Aptana plugin for Eclipse, which is giving me great syntax highlighting, and allows me to manually click to compile a *.scss file into a *.css file. What I would really like to be able to do is get it to automatically compile every time I save, but I cannot figure out how to do this.

I know you can use sass --watch on the command line, but I don't want to have to set this up manually every time I open eclipse, or create a new project.

Has anyone found a good way of achieving this? Is there must be a way of hooking into Aptana's Sass bundle and running it's compile command everytime I save? The accepted answer to this question suggests using a "Program Builder" - but is this really the best solution? If so does anyone have any tips/links to tutorials?

Update: I wrote up a blog post about how to use an ant script as a builder, but I'm still looking for a better way.

Answer

Zed picture Zed · Jan 23, 2016

After lot of tries, I've found that the best solution in Eclipse is to define a simple Builder using the --update sass feature:

  • From the Project menu select "Properties" and choose the "Builders" section.
  • Create a new Builder and select "Program" as configuration type.
  • Choose a name for your launch configuration (SASS?!).
  • Insert the path of your sass installation into the Location field.
  • Use ${project_loc} as working directory.
  • In the Arguments text box insert the configuration parameters you want sass to use and, at the end, specify the --update parameter followed by your sass files directory source followed by ":" and the destination folder for the compiled css files. In my configuration "resources" is the source folder containing the .scss files and "web" is the destination directory containing the compiled .css files. The --update command will check for modifications in the source folder and all sub-folders. Screenshot
  • In the "Build Options" tab just check all options under the "Run the builder:" section. You can also "Specify working set of relevant resources" to launch the builder only when files contained in selected folders are saved. Screenshot
  • Click ok to save your launching configuration.
  • Now try to modify a .scss file in your source directory and then save it, you'll see the sass CLI output in your console window.

The sass CLI will automatically check for modified resources inside the source folder (resources in my configuration) and compile them into the destination folder (web in my configuration). Also, all .sass files that @import the modified resources will be compiled.