From d7f39350d52ff0e77c6bc91f4d6789ec831187c9 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 31 Aug 2011 13:27:29 -0700 Subject: [PATCH] sprockets ignores extensions after .js in build mode. closes #110 --- features/sprockets.feature | 7 ++++++- lib/middleman/core_extensions/sprockets.rb | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/features/sprockets.feature b/features/sprockets.feature index 0d233aa9..80710886 100644 --- a/features/sprockets.feature +++ b/features/sprockets.feature @@ -13,4 +13,9 @@ Feature: Sprockets Scenario: Sprockets should have access to yaml data Given the Server is running at "test-app" When I go to "/javascripts/multiple_engines.js" - Then I should see "Hello One" \ No newline at end of file + Then I should see "Hello One" + + Scenario: Multiple engine files should build correctly + Given a built app at "test-app" + Then "javascripts/multiple_engines.js" should exist at "test-app" and include "Hello One" + And cleanup built app at "test-app" \ No newline at end of file diff --git a/lib/middleman/core_extensions/sprockets.rb b/lib/middleman/core_extensions/sprockets.rb index 41dcd387..4dcaf1c3 100644 --- a/lib/middleman/core_extensions/sprockets.rb +++ b/lib/middleman/core_extensions/sprockets.rb @@ -6,7 +6,19 @@ module Middleman::CoreExtensions::Sprockets class << self def registered(app) app.set :js_compressor, false - + + # Cut off every extension after .js (which sprockets eats up) + app.build_reroute do |destination, request_path| + if !request_path.match(/\.js\./i) + false + else + [ + destination.gsub(/\.js(\..*)$/, ".js"), + request_path.gsub(/\.js(\..*)$/, ".js") + ] + end + end + app.after_configuration do js_env = Middleman::CoreExtensions::Sprockets::JavascriptEnvironment.new(app)