bertramdev / grails-asset-pipeline

Grails Asset Pipeline

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

External Dev Time Directory

phidias51 opened this issue · comments

In my projects the user interface code is primarily Polymer-based. We have a large collection of components that we want to reuse. Our directory structure looks something like this:

/component_lib
   /bower_components
   /corp_components

/grails-project-1
/grails-project-2

Is there a way for us to configure the asset pipeline plugin in each of the grails projects to point to /component_lib. During development it would need to resolve against the /component_lib directory, but when the grails projects are WAR'd then, it would need to pull the components that were used by each of the projects into the WARs.

After a discussion with @phidias51, we have a somewhat common use case. We are both using tools from the "wide world of javascript" such as Bower, jspm, Gulp, etc. to do dependency management with web components, him with Polymer and me with Aurelia and Zurb Foundation. We seem to be at an inflection point for the two worlds of build and dependency management and trying to figure out how best to use gradle and gulp/bower and the asset-pipeline.

My approach has been to separate my app into two directories, one managed by the asset-pipeline and one just served out of the src directory. I have my CSS placed into grails-app/assets/bower_components with a one time pull of bower. Then, I have my javascript and html partials placed into into src/main/webapp where I keep a terminal open for running gulp.

To build, I run a gulp build and then run the gradle build to package all the files from src/main/webapp. I use src/main/webapp because grails will detect file changes and reload them as opposed to src/main/resources/public.

During development I run a gulp watch to detect changes and perform transpilation of my javascript (aurelia) in src/main/webapp.

I do not regularly update my components as I am developing each web component myself as javascript and html partials. They are all in one git repository for my project. However @phidias51 has a shared component library in separate git repositories that are shared in other projects and he has html and javascript that needs to be put into the war. He would like to be able to have dependencies update during war build time.

It seems straightforward to suggest that he would have gradle copy the directories into the war, however, during development time I am not sure how to have asset-pipeline access these files.

We currently use gradle to copy the UI into the grails project for deployment. But that's a less than optimal solution, because we can't cherry pick the components that we want to include, and we can't make use of the bower dependency declarations. Here's a typical use case:

Let's suppose that I have an element called my-card which exists in the shared components directory /component_lib/corp_components/my-element/my-card.html. This element depends on Polymer's paper-card found in /component_lib/bower_components/paper-card/paper-card.html.

Let's suppose that I have a project-specific element that uses my-card. What I want to be able to do is configure the asset pipeline to read the bower files for all of the dependencies in the dependency chain, pick up the right dependencies and put them in my war file whenever I build me war.

Since I want to minimize the numbers of copies of these dependencies that are floating around my hard drive, I want asset pipeline to simply resolve the dependencies to my local /component_lib directory.

This last bit may not be possible, but in any case I want to minimize the number of copies on my drive by whatever means possible.