Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Sass compiling filter for Java web apps

NOTE: As of version 3.2.7 we are using compass to compile your sass!


Compiles sass to css on-the-fly with compass via a j2ee servlet filter


Add this to your web.xml



Create a WEB-INF/sass/config.rb file that looks something like

css_dir = "../../stylesheets"
sass_dir = "."

Put your sass templates in WEB-INF/sass and each request for a css file will regenerate as needed.


Since getting stuff in central is a PITA, add the following to your pom.xml




Download the jar with depenencies


Configuration is done through a combination of filter init parameters and the config.rb file. The following filter init parameters are available to control the execution of the filter:

  • configLocation - the location of the config.rb (default WEB-INF/sass/config.rb)
  • onlyRunWhenKey - the system property or environment variable to check to see if sass compilation should run, use this to turn sass generation off in production
  • onlyRunWhenValue - the corresponding value to check to see if sass compilation should run

You probably only want the css generation to run in development mode and then commit the generated css to source control. This is achieved by the onlyRunWhenKey and onlyRunWhenValue filter init parameters.


With this configuration the filter will check a system property or environment variable called RUNTIME_ENVIRONMENT and only run the sass compilation if that value is equal to local

See the compass config documentation to find out about all the wonderful things you can put in config.rb. For those config options that reference a file or directory, the working directory that compass will be executed in is the directory that contains config.rb.

Try it out

  1. git clone
  2. cd sass-java
  3. mvn jetty:run
  4. wait for maven to download the internet
  5. open http://localhost:8080/sass-java
  6. change src/test/sample-webapp/WEB-INF/sass/application.scss
  7. repeat step 5
  8. be amazed
Something went wrong with that request. Please try again.