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

Commit 10b3c13

Browse files
committed
Search for modules based on their user-defined paths before using the module name
1 parent 3650c16 commit 10b3c13

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

app/helpers/requirejs_helper.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,30 @@ def requirejs_include_tag(name = nil, &block)
4949
end
5050

5151
if Rails.application.config.assets.digest
52-
modules = requirejs.build_config['modules'].map { |m| requirejs.module_name_for m }
52+
modules = requirejs.build_config["modules"].map {|m| requirejs.module_name_for m}
53+
user_paths = requirejs.build_config["paths"] || {}
5354

5455
# Generate digestified paths from the modules spec
5556
paths = {}
56-
modules.each { |m| paths[m] = javascript_path(m).sub /\.js$/, '' }
5757

58-
if run_config.has_key? 'paths'
58+
modules.each do |m|
59+
# Search for modules based on their user-defined paths before using the module name.
60+
paths[m] = javascript_path(user_paths[m] || m).gsub(/\.js$/, "")
61+
end
62+
63+
if run_config.has_key? "paths"
5964
# Add paths for assets specified by full URL (on a CDN)
60-
run_config['paths'].each do |k, v|
65+
run_config["paths"].each do |k, v|
6166
paths[k] = v if v.is_a?(Array) || v =~ /^(https?:)?\/\//
62-
6367
end
6468
end
6569

6670
# Override user paths, whose mappings are only relevant in dev mode
6771
# and in the build_config.
68-
run_config['paths'] = paths
72+
run_config["paths"] = paths
6973
end
7074

71-
run_config['baseUrl'] = base_url(name)
75+
run_config["baseUrl"] = base_url(name)
7276

7377
html.concat(content_tag(:script) do
7478
script = "require.config(#{run_config.to_json});"

0 commit comments

Comments
 (0)