This document should only be referenced if you're NOT using the current technique of the rails/webpacker helpers to place your client-side assets in your
Hot Reloading of Assets For Rails Development
- minimal demo here: The most simple and updated hot reloading setup.
- spec/dummy: Simpler setup used for integration testing this gem.
- shakacode/react-webpack-rails-tutorial. Full featured setup using Twitter bootstrap.
This doc might be outdated. PRs welcome!
High Level Strategy
We'll use a Webpack Dev server on port 3500 to provide the assets to Rails, rather than the asset pipeline, and only during development mode. This is configured via the
Procfile.static provides an alternative that uses "static" assets, similar to a production deployment.
Places to Configure (Files to Examine)
- See the Webpack config files. Note, these examples are now setup for using CSS Modules.
- app/views/layouts/application.html.erb: Uses the view helpers
- See the Procfiles: Procfile.hot and Procfile.static. These:
- Start the webpack processes, depending on the mode or HOT or not.
- Start the rails server, setting an ENV value of REACT_ON_RAILS_ENV to HOT if we're hot loading or else setting this to blank.
- Configure the file Rails asset pipeline files:
- Copy the client/server-rails-hot.js to the your client directory.
- Copy the scripts in the top level and client level
Please refer to the examples linked above in
spec/dummy as these code samples might be out of date.