From 9c07d287711dc5b859345ce35d77b0c7810a31ab Mon Sep 17 00:00:00 2001 From: Alexis Reigel Date: Mon, 20 Jun 2016 15:10:11 +0200 Subject: [PATCH] workaround for react server render error https://github.com/reactjs/react-rails/issues/443#issuecomment-180544359 --- app/assets/javascripts/application.js | 2 +- app/assets/javascripts/server_rendering.js | 2 ++ config/environments/production.rb | 5 +++++ config/initializers/assets.rb | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/server_rendering.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index a0586998..b4491dbd 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -4,11 +4,11 @@ //= require bootstrap-material-design //= require react //= require react_ujs +//= require auto_save //= require components //= require trumbowyg/dist/trumbowyg //= require momentjs/moment //= require bootbox/bootbox -//= require_tree . $(function () { $.material.init(); diff --git a/app/assets/javascripts/server_rendering.js b/app/assets/javascripts/server_rendering.js new file mode 100644 index 00000000..7e6d55c9 --- /dev/null +++ b/app/assets/javascripts/server_rendering.js @@ -0,0 +1,2 @@ +//= require react-server +//= require components diff --git a/config/environments/production.rb b/config/environments/production.rb index 89f90e61..0773d08e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -80,4 +80,9 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # React + config.react.server_renderer_options = { + files: %w(server_rendering.js) + } end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index f600e017..58f13d02 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -18,3 +18,6 @@ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. Rails.application.config.assets.precompile += bower_precompile_paths + +# Workaround for react server side rendering +Rails.application.config.assets.precompile += %w(server_rendering.js)