Open janbiedermann opened 6 years ago
Getting React with Sprockets: setting config.react.variant to :production or :development explicitly is not necessary because that is the default behaviour for react-rails: https://github.com/reactjs/react-rails/blob/ec7124148bb82023a111ee801f3d4b52a7bab4bb/lib/react/rails/railtie.rb#L8
When on webpacker, lap28 edge: i had to set: config.assets.compile = true in config/environments/production.rb
no need for: <%= javascript_pack_tag "client_only" %> <%= javascript_pack_tag "client_and_server" %> in app/views/layout/application.html.erb
also no need for:
config/webpack/custom.js
i think that many of those are now handled from hyperloop/config and autoconfig
i can also deploy with capistrano and get react production variant!
Example for using Sprockets and Webpacker together
config/initializers/hyperloop.rb
Getting React with Sprockets
https://github.com/reactjs/react-rails/issues/715 get react in the correct version for each environment:
With ActionCable
cable.js must be loaded before hyperloop-loader!
JQuery support
Hyperloop offers some support code for integrating opal-jquery. To activate this code, opal jquery must be required on the client side before hyperloop-loader or hyper-component, example for using app/assets/application.rb: <- .rb
if using app/assets/application.js: <- .js
In General
minification with uglifier, in config/environments/production.rb:
For Heroku
something like:
this might be helpful: https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache also:
For Development
because of problems with sprockets cache design and FileStore a MemoryStore cache is recommended, just like for heroku above, maybe larger in size.
Possible Errors:
"#<ExecJS::ProgramError: TypeError: Cannot read property 'serverRender' of undefined>" when prerendering
: cause: react_ujs missing or imported to late