grails 2.1.1 does not reload static resources

2.1k Views Asked by At

I have a fresh grails 2.1.1 installation, windows 7.

Problem: Static resources (CSS) don't reload in development mode.

According to http://grails.1312388.n4.nabble.com/Re-Grails-2-0-CSS-Changes-not-Picked-Up-td3680479.html I've tried in Config.groovy:

environments {
    development {
        grails.resources.processing.enabled = false;
    }
}

Result: no CSS is loaded at all. Chrome needs 30 seconds to load a page, and does not load any CSS.

I reverted that change.

Then, according to http://grails.1312388.n4.nabble.com/disabling-static-resource-stuff-td3827384.html I've tried to uncomment the plugins runtime ":resources:1.1.6"

Now I'm back to how it was initially, CSS files are served but not reloaded.

What works temporarily is the hack mentioned here: http://grails.1312388.n4.nabble.com/The-resources-plugin-is-not-reloading-my-CSS-and-JS-of-a-bundle-td3857137.html

Top append to the url: ?_debugResources=y

How do I make static resources being reloaded in development mode? Shouldn't that be the default anyway? It doesn't make any sense in my opinion to reload gsp's (which it does) but not the static resources.

2

There are 2 best solutions below

2
On

I set the grails.resources.debug flag in Config.groovy on debug to get the URL to be appended like this

 css/main.css?_debugResources=y&n=1386063248351


environments {
    development {
        grails.resources.debug = true
    }
    production {
    }
}
0
On

Any URL in your application can have the query parameter _debugResources=y added to it, and the request will perform no processing. So for example if you are browsing http://localhost:8080/myapp/admin and need to bypass resources, just change the URL in your browser to http://localhost:8080/myapp/admin?_debugResources=y

Reference Link : https://grails-plugins.github.io/grails-resources/guide/8.%20Debugging.html