SASS Compilation
Last updated
Was this helpful?
Last updated
Was this helpful?
Example code is available on .
SASS compilation will happen automatically, during runtime, in all environments except of production environment. This is handy, because we do not have to recompile SASS files after each change.
If automatic compilation of SASS is not happening, make sure productionMode
is set to false
for development environment, in VaadinConfig.groovy
.
Because automatic re-compilation shoud not happen in production, because of performance, Vaadin plugin will compile SASS files for you when you build the production war file, as part of grails prod war
command.
Let's create an example theme that will extend new Valo theme provided by Vaadin 7.3.
Create new folders /VAADIN/themes/mytheme
in web-app
. Then we create new SASS file named styles.scss
in web-app/VAADIN/themes/mytheme
folder.
Add the name of a theme to VaadinConfig.groovy
, in our example mytheme
.
We can also define Vaadin version for SASS compilation by defining sassCompile
variable. If we do not define Vaadin version a default version will be provided by Vaadin plugin.
Then styles.scss
gets compiled into styles.css
when we run grails prod war
command.
This configuration is required for SASS compilation that is executed as part of
grails prod war
command.
The last step is to let Vaadin know what is the active theme. Add @Theme
annotation with name of our custom theme on our UI
class.
Run the app and notice the changed background and the button, which is using Valo theme.
When you add
?debug
as a parameter into URL, you wil see what theme is used as well as other debug logs.