❮ zur Übersicht

Sass support for web applications with jetty and wro4j

  • Autor: messner
  • Datum: 26.05.2014

Suppose we voted for Sass as the css preprocessor of our choice for a web application. Knowing that css must be generated from our Sass code everytime a scss file is modified, we want to set up the project in a way that enables fast turnaround cycles during development.

The Requirements are:

  • generated css should be bundled within the WAR when building the webapp for production on the continuous integration server

  • changes made to Sass resources during development time should be available to the browser without requiring a rebuild of the webapp

One way to fit these requirements is to use Jetty and the Web Resource Optimizer for Java. wro4j provides Sass support with the JRuby based RubySassCssProcessor which can be used both as a pre or post processor. In order to compile our scss into css when building the webapp we have to include the wro4j-maven-plugin into the projects POM:


The plugins run goal is bound to the prepare-package phase, so the WAR will contain the css resource in /css/ after packaging the web application. In addition to the plugin configuration we also have to provide some merging and pre/post processor related configuration settings in wro.xml and wro.properties respectively.


<groups xmlns="http://www.isdc.ro/wro">
  <group name="base">



The configuration settings for caching and the manager factory are necessary for development environment: at development time we want a servlet filter to trigger the css compilation process every time when the browser requests the css.

To enable this mechanism we place the file override-web.xml in directory src/test/resources/


<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" xmlns="http://java.sun.com/xml/ns/javaee">

override-web.xml is a web.xml that Jetty applies to a web application after the application’s own WEB-INF/web.xml which means that it can override values or add new elements. The jetty-maven-plugin allows to configure the location of that file with the overridedescriptor tag:



Finally we configure the build to exclude Sass resources and wro4j configuration from the WAR:



That’s it. With this setup developers are now able to modify scss files and see the resulting css just by reloading the page in the browser.

webapp project structure projectstructure

Tags: Jetty Maven Sass wro4j