Urls Within CSS Files Broken with Grails Resources Plugin 1.2.7

URLs within CSS files broken with Grails resources plugin 1.2.7

According to my comment earlier, this wasn't an issue for me because by default all resources under /images, /css and /js are served as adhoc resources in Grails and I was testing with a .png file from images.

I came across this issue again from my colleague which made me think twice. :) In his case, he was trying to access fonts from /fonts which is provided by a plugin used in the app.

Before trying the below answer, I tried to disable css rewriting by adding the below configuration:

//Not required
//grails.resources.rewrite.css = false

but it made no sense for me as I was dealing with a font resource.

Ultimately, adding this as part of Config.groovy for fonts made the trick. For your case, you would need to do like below:

grails.resources.adhoc.includes = ['/img/**']
//If resource served from a plugin
//grails.resources.adhoc.includes = ['/plugins/**', '/img/**']

If you already have this configuration, it would look something like:

grails.resources.adhoc.includes = [
'/images/**', '/css/**', '/js/**', '/img/**'
]

But as I said you might not need adding adhoc includes for existing resources in a grails app.

Go ahead with

  • grails clean (to be on the safer side)
  • grails run-app.
  • Clean browser cache (I would prefer an incognito mode in Chrome, if Chrome used)
  • Hit app url

It should not complain about the resource any more.

How to link to an image from a CSS file when using the resource plugin 1.2.14

Looks like adding grails.resources.rewrite.css = false can solve my problem. Found here.

Resources plugin - Resource not found even when the files exists

I've solved this by moving the jquery-ui/ folder to js/

And then modified the entry in ApplicationResources.groovy to match the folder changes:

jquery_plugins {
dependsOn 'jquery'
defaultBundle 'plugins' // plugins de jquery

resource url:'js/plugins/placeholder.js', disposition:'head'
resource url:'js/jquery-ui/css/flick/jquery-ui-1.9.0.custom.min.css', disposition:'head'
resource url:'css/plugins/pnotify.css', disposition:'head'
resource url:'js/jquery-ui/js/jquery-ui-1.9.0.custom.min.js', disposition:'head'
resource url:'js/plugins/json.js'
resource url:'js/plugins/jpnotify120.js'
resource url:'js/plugins/jnetworkDetection.js'
}

r:img leads to unlocated resource

The issue was, that I rendered an image from a plugin (but within this plugin). Therefore the plugin tag has to be used everywhere. However the combination with URI is not working. So the missing combination above was:

<li><g:img plugin="zeitfest-office" dir="images" file="zeitfest.png" /></li>

This is the only combination which will work!

Grails resources not working with cache-busting CKEditor release (4.5.5+)

The eventual solution (recommended by a colleague) is to exclude the specific CSS file(s) from being processed by grails resources:

resource url:"thirdparty/ckeditor/skins/moono/editor.css", exclude: "*"

This avoids affecting other files that were either unaffected by the upgraded CKEditor, or benefited from the processing done by grails resources.

Grails is giving resource not found for fullcalendar CSS and JS files

After doing a lot of permutations, this is what worked for me:

 <g:javascript library="full-calendar"/>
<r:layoutResources/>

instead of

<fullcal:resources/>

in the head

EDIT :

A better way would be to add the fullcalender resources to ApplicationResources.groovy and manually add the js and css to /web-app to and add the application library to your page. As the grails plugin for fullcalender has not been updated.

Grails resource tag generating wrong link

Use context path to provide the plugin path and also use absolute:"true" so that the URL starts from project name.

Example-

${resource(dir: 'assets/css', file: "datepicker.css", contextPath :"plugins/ui-plugin-0.1", absolute:"true" )}

<link rel="stylesheet" type="text/css" href="${resource(dir: 'assets/css', file: "datepicker.css", contextPath :"plugins/ui-plugin-0.1", absolute:"true" )}"/>



Related Topics



Leave a reply



Submit