Resource Bundling Issue

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Resource Bundling Issue

kirk
I'm trying to get mutliple CSS and JS files to bundle together using the resources plugin (1.1.5) and Grails 2.0. No matter what I do, the resources are linked in the webpage as separate CSS and JS resource files. I've read all the docs and tried a number of things (including resources 1.1.6) with no luck. The resources are being included and the app works just fine but when I view source I see a different <script> or <link> for each resource. Nothing is combined. I must be missing something here. Thanks. Here is my AppResources.groovy modules = { core { dependsOn 'jquery' dependsOn 'twitter' dependsOn 'showLoadingJQueryPlugin' resource url: 'css/main.css' resource url: 'js/application.js' } showLoadingJQueryPlugin { resource url: 'css/showLoading.css' resource url: 'js/jquery.showLoading.min.js' } twitter { resource url: 'css/bootstrap.min.css' } tinyMCE { defaultBundle false resource url: '/js/tiny_mce/tiny_mce.js', disposition: 'head' } richTextEditor { dependsOn 'tinyMCE' resource url: '/js/rich_text_editor.js', disposition: 'head' } } I have the following in the HEAD of the layout gsp: <r:require module="core"/> <r:layoutResources/> And this is what is included in the head of the webpage: <script src="/editor/plugins/jquery-1.7.1/js/jquery/jquery-1.7.1.min.js?_debugResources=y&n=1329933971418" type="text/javascript" ></script><link href="/editor/css/showLoading.css?_debugResources=y&n=1329933971418" type="text/css" rel="stylesheet" media="screen, projection" />

<link href="/editor/css/bootstrap.min.css?_debugResources=y&n=1329933971418" type="text/css" rel="stylesheet" media="screen, projection" />
<link href="/editor/css/main.css?_debugResources=y&n=1329933971418" type="text/css" rel="stylesheet" media="screen, projection" />


And at the bottom of the page I get:

                <script src="/editor/js/jquery.showLoading.min.js?_debugResources=y&n=1329933971418" type="text/javascript" ></script><script src="/editor/js/application.js?_debugResources=y&n=1329933971418" type="text/javascript" ></script>



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resource Bundling Issue

kirk
Let's try that again, shall we...

I'm trying to get mutliple CSS and JS files to bundle together using the resources plugin (1.1.5) and Grails 2.0. No matter what I do, the resources are linked in the webpage as separate CSS and JS resource files. I've read all the docs and tried a number of things (including resources 1.1.6) with no luck. The resources are being included and the app works just fine but when I view source I see a different script or link for each resource. Nothing is combined. I must be missing something here. Thanks.

Here is my AppResources.groovy

modules = {
    core {
        dependsOn 'jquery'
  dependsOn 'twitter'
                dependsOn 'showLoadingJQueryPlugin'
               
        resource url: 'css/main.css'
                resource url: 'js/application.js'
    }

        showLoadingJQueryPlugin {
        resource url: 'css/showLoading.css'
        resource url: 'js/jquery.showLoading.min.js'
        }
               
    twitter {
        resource url: 'css/bootstrap.min.css'
    }
       
        tinyMCE {
                defaultBundle false
                resource url: '/js/tiny_mce/tiny_mce.js', disposition: 'head'
        }

        richTextEditor {
                dependsOn 'tinyMCE'
                resource url: '/js/rich_text_editor.js', disposition: 'head'
        }
}

I have the following in the HEAD of the layout gsp:

  <r:require module="core"/>

                <r:layoutResources/>



And this is what is included in the head of the webpage:

                <script src="/editor/plugins/jquery-1.7.1/js/jquery/jquery-1.7.1.min.js?_debugResources=y&n=1329933971418" type="text/javascript" ></script><link href="/editor/css/showLoading.css?_debugResources=y&n=1329933971418" type="text/css" rel="stylesheet" media="screen, projection" />

<link href="/editor/css/bootstrap.min.css?_debugResources=y&n=1329933971418" type="text/css" rel="stylesheet" media="screen, projection" />
<link href="/editor/css/main.css?_debugResources=y&n=1329933971418" type="text/css" rel="stylesheet" media="screen, projection" />


And at the bottom of the page I get:

                <script src="/editor/js/jquery.showLoading.min.js?_debugResources=y&n=1329933971418" type="text/javascript" ></script><script src="/editor/js/application.js?_debugResources=y&n=1329933971418" type="text/javascript" ></script>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resource Bundling Issue

David
I haven't tried it myself yet, but this looks like the way to do what you're asking:

http://grails.org/doc/latest/guide/theWebLayer.html, under the section 6.2.5.5 "Optimizing your resources".


Skickat från min iPad

22 feb 2012 kl. 19:23 skrev kirk <[hidden email]>:

> Let's try that again, shall we...
>
> I'm trying to get mutliple CSS and JS files to bundle together using the
> resources plugin (1.1.5) and Grails 2.0. No matter what I do, the resources
> are linked in the webpage as separate CSS and JS resource files. I've read
> all the docs and tried a number of things (including resources 1.1.6) with
> no luck. The resources are being included and the app works just fine but
> when I view source I see a different script or link for each resource.
> Nothing is combined. I must be missing something here. Thanks.
>
> Here is my AppResources.groovy
>
> modules = {
>    core {
>        dependsOn 'jquery'
>        dependsOn 'twitter'
>        dependsOn 'showLoadingJQueryPlugin'
>        
>        resource url: 'css/main.css'
>        resource url: 'js/application.js'
>    }
>
>    showLoadingJQueryPlugin {
>        resource url: 'css/showLoading.css'
>        resource url: 'js/jquery.showLoading.min.js'
>    }
>        
>    twitter {
>        resource url: 'css/bootstrap.min.css'
>    }
>    
>    tinyMCE {
>        defaultBundle false
>        resource url: '/js/tiny_mce/tiny_mce.js', disposition: 'head'
>    }
>
>    richTextEditor {
>        dependsOn 'tinyMCE'
>        resource url: '/js/rich_text_editor.js', disposition: 'head'
>    }
> }
>
> I have the following in the HEAD of the layout gsp:
>
>          <r:require module="core"/>
>
>        <r:layoutResources/>
>
>
>
> And this is what is included in the head of the webpage:
>
>        
> <link href="/editor/css/showLoading.css?_debugResources=y&n=1329933971418"
> type="text/css" rel="stylesheet" media="screen, projection" />
>
> <link href="/editor/css/bootstrap.min.css?_debugResources=y&n=1329933971418"
> type="text/css" rel="stylesheet" media="screen, projection" />
> <link href="/editor/css/main.css?_debugResources=y&n=1329933971418"
> type="text/css" rel="stylesheet" media="screen, projection" />
>
>
> And at the bottom of the page I get:
>
>        
>
>
>
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Resource-Bundling-Issue-tp4411239p4411261.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resource Bundling Issue

Jonathan Andrew Ong
Can you try putting a defaultBundle value in each of the declarations? I believe that should combine it into a single file for js and another for css.

On Thu, Feb 23, 2012 at 6:59 AM, David Tiselius <[hidden email]> wrote:
I haven't tried it myself yet, but this looks like the way to do what you're asking:

http://grails.org/doc/latest/guide/theWebLayer.html, under the section 6.2.5.5 "Optimizing your resources".


Skickat från min iPad

22 feb 2012 kl. 19:23 skrev kirk <[hidden email]>:

> Let's try that again, shall we...
>
> I'm trying to get mutliple CSS and JS files to bundle together using the
> resources plugin (1.1.5) and Grails 2.0. No matter what I do, the resources
> are linked in the webpage as separate CSS and JS resource files. I've read
> all the docs and tried a number of things (including resources 1.1.6) with
> no luck. The resources are being included and the app works just fine but
> when I view source I see a different script or link for each resource.
> Nothing is combined. I must be missing something here. Thanks.
>
> Here is my AppResources.groovy
>
> modules = {
>    core {
>        dependsOn 'jquery'
>        dependsOn 'twitter'
>        dependsOn 'showLoadingJQueryPlugin'
>
>        resource url: 'css/main.css'
>        resource url: 'js/application.js'
>    }
>
>    showLoadingJQueryPlugin {
>        resource url: 'css/showLoading.css'
>        resource url: 'js/jquery.showLoading.min.js'
>    }
>
>    twitter {
>        resource url: 'css/bootstrap.min.css'
>    }
>
>    tinyMCE {
>        defaultBundle false
>        resource url: '/js/tiny_mce/tiny_mce.js', disposition: 'head'
>    }
>
>    richTextEditor {
>        dependsOn 'tinyMCE'
>        resource url: '/js/rich_text_editor.js', disposition: 'head'
>    }
> }
>
> I have the following in the HEAD of the layout gsp:
>
>          <r:require module="core"/>
>
>        <r:layoutResources/>
>
>
>
> And this is what is included in the head of the webpage:
>
>
> <link href="/editor/css/showLoading.css?_debugResources=y&n=1329933971418"
> type="text/css" rel="stylesheet" media="screen, projection" />
>
> <link href="/editor/css/bootstrap.min.css?_debugResources=y&n=1329933971418"
> type="text/css" rel="stylesheet" media="screen, projection" />
> <link href="/editor/css/main.css?_debugResources=y&n=1329933971418"
> type="text/css" rel="stylesheet" media="screen, projection" />
>
>
> And at the bottom of the page I get:
>
>
>
>
>
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Resource-Bundling-Issue-tp4411239p4411261.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resource Bundling Issue

David
I tried this (http://grails.org/doc/latest/guide/theWebLayer.html#optimizingYourResources)
on my current project now and it works.
By putting for instance bundle:  'main' after two resources, like this:
  ...
  resource url: 'js/application.js', bundle:  'main'
  ...
  resource url: 'js/jquery.showLoading.min.js', bundle:  'main'
  ...

these two are combined into one file.

/David

On Thu, Feb 23, 2012 at 1:26 AM, Jonathan Andrew Ong
<[hidden email]> wrote:

> Can you try putting a defaultBundle value in each of the declarations? I
> believe that should combine it into a single file for js and another for
> css.
>
>
> On Thu, Feb 23, 2012 at 6:59 AM, David Tiselius <[hidden email]>
> wrote:
>>
>> I haven't tried it myself yet, but this looks like the way to do what
>> you're asking:
>>
>> http://grails.org/doc/latest/guide/theWebLayer.html, under the section
>> 6.2.5.5 "Optimizing your resources".
>>
>>
>> Skickat från min iPad
>>
>> 22 feb 2012 kl. 19:23 skrev kirk <[hidden email]>:
>>
>> > Let's try that again, shall we...
>> >
>> > I'm trying to get mutliple CSS and JS files to bundle together using the
>> > resources plugin (1.1.5) and Grails 2.0. No matter what I do, the
>> > resources
>> > are linked in the webpage as separate CSS and JS resource files. I've
>> > read
>> > all the docs and tried a number of things (including resources 1.1.6)
>> > with
>> > no luck. The resources are being included and the app works just fine
>> > but
>> > when I view source I see a different script or link for each resource.
>> > Nothing is combined. I must be missing something here. Thanks.
>> >
>> > Here is my AppResources.groovy
>> >
>> > modules = {
>> >    core {
>> >        dependsOn 'jquery'
>> >        dependsOn 'twitter'
>> >        dependsOn 'showLoadingJQueryPlugin'
>> >
>> >        resource url: 'css/main.css'
>> >        resource url: 'js/application.js'
>> >    }
>> >
>> >    showLoadingJQueryPlugin {
>> >        resource url: 'css/showLoading.css'
>> >        resource url: 'js/jquery.showLoading.min.js'
>> >    }
>> >
>> >    twitter {
>> >        resource url: 'css/bootstrap.min.css'
>> >    }
>> >
>> >    tinyMCE {
>> >        defaultBundle false
>> >        resource url: '/js/tiny_mce/tiny_mce.js', disposition: 'head'
>> >    }
>> >
>> >    richTextEditor {
>> >        dependsOn 'tinyMCE'
>> >        resource url: '/js/rich_text_editor.js', disposition: 'head'
>> >    }
>> > }
>> >
>> > I have the following in the HEAD of the layout gsp:
>> >
>> >          <r:require module="core"/>
>> >
>> >        <r:layoutResources/>
>> >
>> >
>> >
>> > And this is what is included in the head of the webpage:
>> >
>> >
>> > <link
>> > href="/editor/css/showLoading.css?_debugResources=y&n=1329933971418"
>> > type="text/css" rel="stylesheet" media="screen, projection" />
>> >
>> > <link
>> > href="/editor/css/bootstrap.min.css?_debugResources=y&n=1329933971418"
>> > type="text/css" rel="stylesheet" media="screen, projection" />
>> > <link href="/editor/css/main.css?_debugResources=y&n=1329933971418"
>> > type="text/css" rel="stylesheet" media="screen, projection" />
>> >
>> >
>> > And at the bottom of the page I get:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> > http://grails.1312388.n4.nabble.com/Resource-Bundling-Issue-tp4411239p4411261.html
>> > Sent from the Grails - user mailing list archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe from this list, please visit:
>> >
>> >    http://xircles.codehaus.org/manage_email
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Resource Bundling Issue

kirk
Solved It. Thanks for everyone's replies. I didn't realize that I had "grails.resources.debug=true" in config.groovy which apparently disables the bundling of resources. Once I removed that property, everything bundled together in each module. To get multiple modules to bundle together I just added the "defaultBundle 'core'" to each module.
Loading...