Reputation: 282
Before posting this question, I took the trouble to Google this issue, but found that clearly I'm in the (extreme) minority so I'm obviously missing something. I've tried on more than one occassion to incorporate the asset-pipeline Grails plugin into my projects, but each time I find myself reverting to the resources plugin. Bottom line: I find the resource plugin far more intuitive and expressive than the 'anything goes' asset-pipeline, despite the underlying bells and whistles offered by the asset-pipeline plugin.
Probably the most confusing thing to me, is the way that resources are declared in either. In the resources plugin for example, I can define the fancybox resources as follows:
'fancybox' {
dependsOn 'jquery'
resource url: '/js/fancybox/jquery.fancybox.css'
resource url: '/js/fancybox/helpers/jquery.fancybox-buttons.css', attrs: [v: '2.1.5']
resource url: '/js/fancybox/jquery.fancybox.js', attrs: [v: '2.1.5']
resource url: '/js/fancybox/helpers/jquery.fancybox-buttons.js', attrs: [v: '2.1.5']
resource url: '/js/fancybox/helpers/jquery.fancybox-media.js', attrs: [v: '2.1.5']
}
There. Simple. That's the fancybox 'package' and it depends on jquery.
For asset pipeline however, I have to declare some weird non-standard convention as follows:
/*
*= require jquery.fancybox
*= require jquery.fancybox-buttons
*/
Then I'll need to refer to that file somewhere in application.css, and as if by magic, asset-pipeline will magically combine them for me with some convoluted logic that I have to keep looking up in the documentation to remind myself ( I don't even know if the above is correct, because I can never get asset-pipeline to work for me). However all my declarations are broken up across multiple .css files, rather than one nice all-in-one location like ApplicationResources.groovy, and I've got no idea what other plugins are declaring other assets unbeknownst to me, whereas with resources plugin, if it isn't in ApplicationResources.groovy, it doesn't exist.
Yet, as I say, I find no articles preferring resources plugin. Everybody appears to have 'drunk the Kool-Aid' on the asset-pipeline. What are the magic pro's that I'm clearly missing? It seems far more convoluted and confusing. What gives?
Upvotes: 0
Views: 476
Reputation: 8587
I really don't think there is an answer to your question since you are trying to raise a debate rather than focusing on a given issue / problem that you wish to fix. You have hit issues but haven't discussed or given what you have tried in a clear manner that maybe someone else can guide you with.
So far as the change from resources to assets, isn't that how frameworks work ? things change and so the framework moves on. You still have the option of resources.
In assets you can define the structure in the application.js and css and if you disable tree then it won't load up everything which I think is one of your issues.
I did a google search on the topic and unsure if you have come across the following links, well worth a read/look:
https://www.slideshare.net/AliTanwir/grails-asset-pipeline-plugin
Upvotes: 0