//Load the requirejs optimizer
var requirejs = require('<%= rjs_path %>'),
  //Set up basic config, include config that is
  //common to all the optimize() calls.
  baseConfig = <%=
    modifiedHash = build_config.select {|k, _| k != "modules"}
    pathsHash = modifiedHash["paths"]
    modifiedHash["dir"] = self.target_dir
    modifiedHash["paths"] = pathsHash.select {|_, v| !v.is_a?(Array)} if !pathsHash.nil?

    JSON.pretty_generate(modifiedHash)
  %>;

baseConfig.modules = [
<% build_config['modules'].each do |m| %>
<%= JSON.pretty_generate(m) %>,
<% end %>
];

requirejs.optimize(baseConfig);

//Load the requirejs optimizer
var requirejs = require('<%= rjs_path %>'),
  //Set up basic config, include config that is
  //common to all the optimize() calls.
  baseConfig = <%=
    modifiedHash = build_config.select {|k, _| k != "modules"}
    pathsHash = modifiedHash["paths"]
    modifiedHash["dir"] = self.target_dir.to_s
    modifiedHash["paths"] = pathsHash.select {|_, v| !v.is_a?(Array)} if !pathsHash.nil?

    JSON.pretty_generate(modifiedHash)
  %>;

baseConfig.modules = [
<% build_config['modules'].each do |m| %>
<%= JSON.pretty_generate(m) %>,
<% end %>
];

requirejs.optimize(baseConfig);

Fix invalid dir value in build config.
Fix invalid dir value in build config.

Convert target_dir path config to a string to ensure json structure is
valid. Closes #165.
