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

Commit d6faff8

Browse files
committed
Update the r.js driver to handle CDN paths with the recent shift to whole-project optimization
Fixes #167.
1 parent 8785162 commit d6faff8

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

lib/requirejs/rails/rjs_driver.js.erb

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
//Load the requirejs optimizer
2-
var requirejs = require('<%= rjs_path %>'),
3-
//Set up basic config, include config that is
4-
//common to all the optimize() calls.
5-
baseConfig = <%=
6-
modifiedHash = build_config.select {|k, _| k != "modules"}
7-
pathsHash = modifiedHash["paths"]
8-
modifiedHash["dir"] = build_dir.to_s
9-
modifiedHash["paths"] = pathsHash.select {|_, v| !v.is_a?(Array)} if !pathsHash.nil?
1+
var requirejs = require(<%= rjs_path.to_s.dump %>)
2+
var baseConfig = <%=
3+
cdn_pattern = Regexp.new("\\Ahttps?://")
104

11-
JSON.pretty_generate(modifiedHash)
12-
%>;
5+
modifiedHash = build_config.select { |k, _| k != "modules" }
6+
pathsHash = modifiedHash["paths"]
7+
modifiedHash["dir"] = build_dir.to_s
8+
modifiedHash["paths"] = Hash[pathsHash
9+
.select do |_, v|
10+
!v.is_a?(Array)
11+
end.map do |k, v|
12+
[k, if !cdn_pattern.match(v) then v else "empty:" end]
13+
end
14+
] if !pathsHash.nil?
15+
16+
JSON.pretty_generate(modifiedHash)
17+
%>;
1318

1419
baseConfig.modules = [
15-
<% build_config['modules'].each do |m| %>
16-
<%= JSON.pretty_generate(m) %>,
20+
<% build_config["modules"].each do |m| %>
21+
<%= JSON.pretty_generate(m) %>,
1722
<% end %>
1823
];
1924

0 commit comments

Comments
 (0)