Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails won't load changes done in static resources (except when restarting)

Tags:

caching

grails

I have an annoying problem with my new grails app. I'm trying to mock up a design for a site that I will be making but whenever I do changes in my css it won't affect the running application. No matter how big changes I do I have to stop the application and then run it again.

This is very frustrating, I've turned of cache in Chrome and even if I go to the specific document the resource is still the old. What can I do to solve this problem? I can make changes in my gsp files and the changes will appear but not in my css.

I am currently loading the resource within a layout file like this:

<link rel="stylesheet" href="${resource(dir: 'css', file: 'app.css')}" type="text/css">

If you need me to provide any more information, please just ask. I am using grails 2.2.0.

like image 264
Ms01 Avatar asked Feb 25 '13 17:02

Ms01


2 Answers

Add this to your Config.groovy (probably just for development)

grails.resources.debug = true

Read the docs for more info.

like image 50
Gregg Avatar answered Oct 15 '22 04:10

Gregg


It looks like Gregg's answer doesn't work for 1.3.7 (maybe that is something added in 2.x?). A method I found that makes quick CSS updates possible is to include a separate GSP as a template in the page header.

That is, create a file called "_css.gsp" (underscore prefix is required) in the same directory as your view files, fill it with standard css surrounded by html style tags, and then include the following in your layout header or page:

<g:render template="css" />

With that in place, the content of _css.gsp is injected into the page. And I can make changes to _css.gsp and they are immediately reflected after page refresh without having to restart Grails. Hope this helps someone in Grails pre-2.x!

like image 29
Nathan Beach Avatar answered Oct 15 '22 06:10

Nathan Beach