I am developing a grails application. I want the browser page to refresh the changes/edits in code on the fly without manually hitting the refresh button everytime. I tried LiveReload but couldn’t get it working with the grails server. Is there any other application for this purpose? I use Intellij Idea IDE for coding.
Share
What does Grails do:
Grails automatically recompiles changes made to Java & Groovy source code. It can, by using the correct plugins, also automatically recompile Less, Sass, … files.
What does LiveReload do:
LiveReload monitors files & folders on your file system and signals a browser to refresh when one of the monitored files change.
How to combine both:
Configure LiveReload to monitor different sub folders of your Grails project. Add the different Grails resources (views, web-app/js, web-app/css, src/groovy, … ) as separate monitored folders. You also do not want liveReload to compile Less, Sass, CoffeeScript, … resources since Grails handles the recompilation.
Recompilation of resources by Grails can take some time, so we want to configure the waiting time for each resource in LiveReload accordingly. Otherwise the browser would refresh before the changed resources are made available by Grails.
For example for my folder with Less files the waiting time is set to 4 seconds, since recompiling most Less files takes at least a few seconds. The waiting time for my folder with js files is set to 1 second. It takes some experimentation to find the optimal settings for your project and system.