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

Commit

Permalink
Merge pull request #254 from sun16/master
Browse files Browse the repository at this point in the history
Fix almond build
  • Loading branch information
carsomyr committed Dec 31, 2015
2 parents 73feaaf + ad87f76 commit 9008038
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/requirejs/rails/rjs_driver.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ cdn_pattern = Regexp.new("\\Ahttps?://")

modifiedHash = build_config.select { |k, _| k != "modules" }
pathsHash = modifiedHash["paths"]
modifiedHash["dir"] = build_dir.to_s

case loader
when :requirejs
modifiedHash['dir'] = build_dir.to_s
when :almond
almond_module = build_config['modules'][0]
modifiedHash.merge!(almond_module)
modifiedHash['out'] = build_dir + (module_name_for(almond_module) + '.js')
end

modifiedHash["paths"] = Hash[
pathsHash.map do |k, v|
[k, v.is_a?(Array) || cdn_pattern.match(v) ? "empty:" : v]
Expand All @@ -14,10 +23,12 @@ modifiedHash["paths"] = Hash[
JSON.pretty_generate(modifiedHash)
%>;

<% unless loader == :almond %>
baseConfig.modules = [
<% build_config["modules"].each do |m| %>
<%= JSON.pretty_generate(m) %>,
<% end %>
];
<% end %>

requirejs.optimize(baseConfig);

0 comments on commit 9008038

Please sign in to comment.