diff --git a/lib/requirejs/rails/config.rb b/lib/requirejs/rails/config.rb index 93862abf..aa039987 100644 --- a/lib/requirejs/rails/config.rb +++ b/lib/requirejs/rails/config.rb @@ -88,7 +88,7 @@ def initialize(application) uglify uglify2 useStrict - wrap + wrapShim } end @@ -133,6 +133,9 @@ def user_config=(cfg) if url = cfg.delete('baseUrl') raise Requirejs::ConfigError, "baseUrl is not needed or permitted in the configuration" end + # delete any cached configs, will be lazily resolved + self.delete(:build_config) + self.delete(:run_config) self[:user_config] = cfg end diff --git a/lib/requirejs/rails/rjs_driver.js.erb b/lib/requirejs/rails/rjs_driver.js.erb index f544037a..7327ad41 100644 --- a/lib/requirejs/rails/rjs_driver.js.erb +++ b/lib/requirejs/rails/rjs_driver.js.erb @@ -2,7 +2,7 @@ var requirejs = require(<%= rjs_path.to_s.dump %>) var baseConfig = <%= cdn_pattern = Regexp.new("\\Ahttps?://") -modifiedHash = build_config.select { |k, _| k != "modules" } +modifiedHash = build_config.select { |k, _| k != "modules" && k != "onBuildRead"} pathsHash = modifiedHash["paths"] modifiedHash["dir"] = build_dir.to_s modifiedHash["paths"] = Hash[ @@ -14,6 +14,10 @@ modifiedHash["paths"] = Hash[ JSON.pretty_generate(modifiedHash) %>; +<% if build_config["onBuildRead"] %> +baseConfig.onBuildRead = <%= build_config["onBuildRead"] %> +<% end %> + baseConfig.modules = [ <% build_config["modules"].each do |m| %> <%= JSON.pretty_generate(m) %>,