rails/rails — Issue #3380: Asset pipeline not happy with sub-repos
Author: jwhitley
Created: 2011-10-20 18:13:21+00:00
State: open

### Repro steps:

1. `rails new foo`
1. `cd foo`
1. `mkdir vendor/assets/javascripts`
1. `cd vendor/assets/javascripts`
1. `git clone https://github.com/mbostock/d3.git` (or some other JS lib via git, tarball, etc.)
1. `cd ../../..`
1. Add `//= require d3/d3.js` to application.js
1. `rake assets:precompile`

### Expected result:

I get a built application.js plus any other stock assets under `public/assets`.

### Actual result:

I get the usual assets, plus a partial skeleton of the entire `d3` directory tree is copied into `public/assets`. The `d3` tree contains only non-JS cruft that I don't want, such as subdirs, HTML example files, READMEs, etc. that were interpreted as "assets".

### Notes:

I'm ramping up on the asset pipeline, and after a little RTFS it's now clear that my expectation that only JS-related stuff would be picked up from `.../javascripts` (and/or via a directive inside a .js file) was naïve. I was also surprised to see the `d3` subdir appear at all since I had no `require_tree d3` directive. Nevertheless, I want to be able to drop a JS library tree (via submodule, tarball, etc.) into my repo, tell Sprockets about the specific assets that I want pulled into the pipeline, and not have all-asset-hell break loose. ;-)

My temporary workaround is to move the external tree out of `config.assets.paths` and have a rake prereq that copies just the needed files into place. Not very DRY, since I have to maintain the manifest of files to pull in via my rake task as well as in Sprockets directives (e.g. via application.js).