Browse files

Revert broken upstream "fix" to sprockets; add correct fix

Rails upstream got a "fix" to an issue with Sprockets not acting as
advertised with respect to directories and automatically finding
index.* files if appropriate during assets precompile.  The "fix"
didn't fix that issue, and instead created a new one where existing
index.* files got ignored.

This commit removes the broken fix, and creates a correct one.

Rails issue:

Incorrect fix:
  • Loading branch information...
1 parent b57fa0b commit 424da34bf0dd17ea4c8a0374cca7df4fa2cf0c3b Russell Pickett committed Jun 6, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 actionpack/lib/sprockets/static_compiler.rb
@@ -16,8 +16,8 @@ def initialize(env, target, paths, options = {})
def compile
manifest = {}
env.each_logical_path do |logical_path|
- if File.basename(logical_path)[/[^\.]+/, 0] == 'index'
- logical_path.sub!(/\/index\./, '.')
+ if
route Jun 7, 2012

each_logical_path doesn't operate with directories, each logical path is always file.

emersonrp Jun 7, 2012

The documentation at the link above says that specifying assets by directory name is supported, and that the intended behavior is that it use any index.(css|js) files from that directory as a manifest.

The previous commit changes index.* filenames into directory names inside each_logical_path, which is the inverse of the documented behavior. As you point out. it doesn't make any sense because each_logical_path doesn't work with directories. And in any case, it introduces a new bug -- it prevents any existing assets named index.* from being precompiled which is how I got here in the first place.

This commit changes directory names into index.* filenames inside each_logical_path, as the documentation describes.

+ logical_path.sub!(/(\.[^\.]+)$/, "/index\1")
next unless compile_path?(logical_path)
if asset = env.find_asset(logical_path)

0 comments on commit 424da34

Please sign in to comment.