diff --git a/actionpack/lib/sprockets/static_compiler.rb b/actionpack/lib/sprockets/static_compiler.rb index 32a9d66e6ed3f..2e2db4b760feb 100644 --- a/actionpack/lib/sprockets/static_compiler.rb +++ b/actionpack/lib/sprockets/static_compiler.rb @@ -16,6 +16,9 @@ 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\./, '.') + end next unless compile_path?(logical_path) if asset = env.find_asset(logical_path) manifest[logical_path] = write_asset(asset) diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 68451cdb33577..4da1dc33aa322 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -114,6 +114,15 @@ def precompile! assert !File.exists?("#{app_path}/public/assets/something.else.css") end + test "precompile something.js for directory containing index file" do + add_to_config "config.assets.precompile = [ 'something.js' ]" + app_file "app/assets/javascripts/something/index.js.erb", "alert();" + + precompile! + + assert File.exists?("#{app_path}/public/assets/something.js") + end + test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do add_to_config "config.assets.digest = true" add_to_config "config.action_controller.perform_caching = false"