Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 65744e3

Browse files
committed
use sprockets for asset lookup
1 parent 5e33712 commit 65744e3

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

lib/requirejs/rails/builder.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ def build
1414
@config.tmp_dir
1515
end
1616

17-
def digest_for(path)
18-
if !::Rails.application.assets.file_digest(path).nil?
19-
::Rails.application.assets.file_digest(path).hexdigest
20-
else
21-
raise Requirejs::BuildError, "Cannot compute digest for missing asset: #{path}"
22-
end
23-
end
24-
2517
def generate_rjs_driver
2618
templ = Erubis::Eruby.new(@config.driver_template_path.read)
2719
@config.driver_path.open('w') do |f|

lib/tasks/requirejs-rails_tasks.rake

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,14 @@ OS X Homebrew users can use 'brew install node'.
106106
original_cache = requirejs.env.cache
107107
requirejs.env.cache = nil
108108

109-
requirejs.env.each_logical_path do |logical_path|
110-
m = bower_json_pattern.match(logical_path)
111-
bower_logical_path = m && "#{m[1]}#{js_ext}"
109+
requirejs.env.logical_paths do |logical_path|
112110

113-
next \
114-
if !(requirejs.config.asset_allowed?(logical_path) || bower_logical_path)
111+
next if ! requirejs.config.asset_allowed?(logical_path)
115112

116113
asset = requirejs.env.find_asset(logical_path)
117114

118115
if asset
119-
# If a `bower.json` was found, then substitute the logical path with the parsed module name.
120-
filename = requirejs.config.source_dir.join(bower_logical_path || asset.logical_path)
116+
filename = requirejs.config.source_dir.join(asset.logical_path)
121117
filename.dirname.mkpath
122118
asset.write_to(filename)
123119
end
@@ -149,8 +145,10 @@ OS X Homebrew users can use 'brew install node'.
149145
task digestify_and_compress: ["requirejs:setup"] do
150146
requirejs.config.build_config['modules'].each do |m|
151147
asset_name = "#{requirejs.config.module_name_for(m)}.js"
148+
asset = requirejs.env.find_asset(asset_name)
149+
152150
built_asset_path = requirejs.config.build_dir.join(asset_name)
153-
digest_name = asset_name.sub(/\.(\w+)$/) { |ext| "-#{requirejs.builder.digest_for(built_asset_path)}#{ext}" }
151+
digest_name = asset.digest_path
154152
digest_asset_path = requirejs.config.target_dir + digest_name
155153

156154
# Ensure that the parent directory `a/b` for modules with names like `a/b/c` exist.

0 commit comments

Comments
 (0)