Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse plugin to automatically compile Sass files [closed]

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.

like image 943
jackocnr Avatar asked Feb 24 '12 12:02

jackocnr


People also ask

How to use sass on Eclipse?

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?!).

How Sass is compiled?

Sass works in such a way that when you write your styles in a . scss file, it gets compiled into a regular CSS file. The CSS code is then loaded into the browser. That is why it's called a Preprocessor.


2 Answers

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.

like image 125
Zed Avatar answered Sep 25 '22 21:09

Zed


there is a watch switch for the sass comiler.
which rebuild the output (css) file everytime the source (scss,sass) change.

Quoting from : http://sass-lang.com/documentation/file.SASS_REFERENCE.html#using_sass

Using Sass

Sass can be used in three ways: as a command-line tool, as a standalone Ruby module, and as a plugin for any Rack-enabled framework, including Ruby on Rails and Merb. The first step for all of these is to install the Sass gem:

gem install sass If you’re using Windows, you may need to install Ruby first.

To run Sass from the command line, just use

sass input.scss output.css You can also tell Sass to watch the file and update the CSS every time the Sass file changes:

sass --watch input.scss:output.css If you have a directory with many Sass files,
you can also tell Sass to watch the entire directory:

sass --watch app/sass:public/stylesheets Use sass --help for full documentation.

Using Sass in Ruby code is very simple. After installing the Sass gem, you can use it by running require "sass" and using Sass::Engine like so:

engine = Sass::Engine.new("#main {background-color: #0000ff}", :syntax => :scss) engine.render #=> "#main { background-color: #0000ff; }\n"

like image 3
Tomer W Avatar answered Sep 23 '22 21:09

Tomer W