react_on_rails 12.0.1 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +12 -2
  3. data/.eslintrc +2 -1
  4. data/.github/workflows/lint-js-and-ruby.yml +53 -0
  5. data/.github/workflows/main.yml +178 -0
  6. data/.github/workflows/package-js-tests.yml +35 -0
  7. data/.github/workflows/rspec-package-specs.yml +45 -0
  8. data/.prettierrc +0 -3
  9. data/.rubocop.yml +46 -38
  10. data/.travis.yml +3 -1
  11. data/CHANGELOG.md +39 -11
  12. data/CONTRIBUTING.md +4 -3
  13. data/Gemfile +1 -33
  14. data/Gemfile.development_dependencies +51 -0
  15. data/NEWS.md +5 -0
  16. data/README.md +66 -57
  17. data/SUMMARY.md +1 -1
  18. data/docs/{basics → additional-details}/generator-details.md +1 -6
  19. data/docs/{outdated → additional-details}/manual-installation-overview.md +6 -6
  20. data/docs/additional-details/recommended-project-structure.md +69 -0
  21. data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +10 -0
  22. data/docs/api/javascript-api.md +2 -2
  23. data/docs/api/redux-store-api.md +3 -3
  24. data/docs/api/view-helpers-api.md +7 -8
  25. data/docs/basics/client-vs-server-rendering.md +4 -2
  26. data/docs/basics/configuration.md +42 -25
  27. data/docs/basics/deployment.md +2 -2
  28. data/docs/basics/hmr-and-hot-reloading-with-the-webpack-dev-server.md +64 -9
  29. data/docs/{outdated → basics}/how-react-on-rails-works.md +8 -9
  30. data/docs/basics/installation-into-an-existing-rails-app.md +13 -6
  31. data/docs/basics/react-server-rendering.md +8 -5
  32. data/docs/basics/rspec-configuration.md +10 -10
  33. data/docs/{tutorial.md → basics/tutorial.md} +28 -30
  34. data/docs/basics/upgrading-react-on-rails.md +41 -18
  35. data/docs/basics/webpack-configuration.md +14 -22
  36. data/docs/contributor-info/linters.md +5 -6
  37. data/docs/contributor-info/pull-requests.md +2 -4
  38. data/docs/contributor-info/releasing.md +1 -1
  39. data/docs/home.md +382 -0
  40. data/docs/{outdated → javascript}/code-splitting.md +5 -5
  41. data/docs/{additional-reading → javascript}/converting-from-custom-webpack-config-to-rails-webpacker-config.md +3 -3
  42. data/docs/{additional-reading → javascript}/images.md +5 -6
  43. data/docs/{articles.md → misc/articles.md} +1 -1
  44. data/docs/misc/doctrine.md +5 -6
  45. data/docs/outdated/deferred-rendering.md +39 -0
  46. data/docs/outdated/rails-assets-relative-paths.md +3 -3
  47. data/docs/outdated/rails-assets.md +8 -8
  48. data/docs/outdated/rails3.md +2 -2
  49. data/docs/{additional-reading → rails}/convert-rails-5-api-only-app.md +1 -1
  50. data/docs/rails-webpacker-react-integration-options.md +182 -0
  51. data/docs/testimonials/testimonials.md +6 -6
  52. data/lib/generators/react_on_rails/base_generator.rb +8 -1
  53. data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
  54. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +8 -2
  55. data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +1 -1
  56. data/lib/generators/react_on_rails/templates/dev_tests/spec/{features → system}/hello_world_spec.rb +2 -2
  57. data/lib/react_on_rails/configuration.rb +2 -0
  58. data/lib/react_on_rails/git_utils.rb +3 -3
  59. data/lib/react_on_rails/helper.rb +15 -9
  60. data/lib/react_on_rails/locales/base.rb +3 -3
  61. data/lib/react_on_rails/locales/to_js.rb +0 -4
  62. data/lib/react_on_rails/locales/to_json.rb +0 -4
  63. data/lib/react_on_rails/prerender_error.rb +1 -1
  64. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +6 -6
  65. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
  66. data/lib/react_on_rails/test_helper.rb +2 -0
  67. data/lib/react_on_rails/utils.rb +24 -4
  68. data/lib/react_on_rails/version.rb +1 -1
  69. data/lib/react_on_rails/webpacker_utils.rb +9 -5
  70. data/lib/tasks/assets.rake +20 -11
  71. data/package.json +24 -29
  72. data/rakelib/docker.rake +0 -5
  73. data/rakelib/lint.rake +3 -9
  74. data/rakelib/release.rake +27 -13
  75. data/rakelib/run_rspec.rake +10 -11
  76. data/rakelib/task_helpers.rb +16 -4
  77. data/react_on_rails.gemspec +3 -17
  78. data/yarn.lock +2272 -4960
  79. metadata +50 -225
  80. data/docs/additional-reading/upgrade-webpacker-v3-to-v4.md +0 -10
  81. data/docs/additional-reading/webpack-dev-server.md +0 -15
  82. data/docs/basics/recommended-project-structure.md +0 -77
  83. data/ruby-lint.yml +0 -25
  84. /data/docs/{basics → additional-details}/migrating-from-react-rails.md +0 -0
  85. /data/docs/{additional-reading → additional-details}/updating-dependencies.md +0 -0
  86. /data/docs/{additional-reading → deployment}/elastic-beanstalk.md +0 -0
  87. /data/docs/{basics → deployment}/heroku-deployment.md +0 -0
  88. /data/docs/{additional-reading → javascript}/angular-js-integration-migration.md +0 -0
  89. /data/docs/{additional-reading → javascript}/asset-pipeline.md +0 -0
  90. /data/docs/{additional-reading → javascript}/capistrano-deployment.md +0 -0
  91. /data/docs/{additional-reading → javascript}/credits.md +0 -0
  92. /data/docs/{additional-reading → javascript}/foreman-issues.md +0 -0
  93. /data/docs/{additional-reading → javascript}/node-dependencies-and-npm.md +0 -0
  94. /data/docs/{additional-reading → javascript}/react-and-redux.md +0 -0
  95. /data/docs/{additional-reading → javascript}/react-helmet.md +0 -0
  96. /data/docs/{additional-reading → javascript}/react-router.md +0 -0
  97. /data/docs/{additional-reading → javascript}/server-rendering-tips.md +0 -0
  98. /data/docs/{additional-reading → javascript}/troubleshooting-when-using-webpacker.md +0 -0
  99. /data/docs/{additional-reading → javascript}/webpack-v1-notes.md +0 -0
  100. /data/docs/{additional-reading → javascript}/webpack.md +0 -0
  101. /data/docs/{coding-style → misc}/style.md +0 -0
  102. /data/docs/{additional-reading → misc}/tips.md +0 -0
  103. /data/docs/{additional-reading → rails}/rails-engine-integration.md +0 -0
  104. /data/docs/{additional-reading → rails}/rails_view_rendering_from_inline_javascript.md +0 -0
  105. /data/docs/{additional-reading → rails}/turbolinks.md +0 -0
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem "webpacker"
4
+ gem "bootsnap", require: false
5
+ gem "rails"
6
+ gem "sqlite3"
7
+ gem "sass-rails"
8
+ gem "uglifier"
9
+ gem "jquery-rails"
10
+ gem "puma"
11
+
12
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
13
+ gem "turbolinks" if ENV["DISABLE_TURBOLINKS"].nil? || ENV["DISABLE_TURBOLINKS"].strip.empty?
14
+
15
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
16
+ gem "jbuilder"
17
+ # bundle exec rake doc:rails generates the API under doc/api.
18
+ gem "sdoc", group: :doc
19
+
20
+ gem "sprockets"
21
+
22
+ gem "amazing_print"
23
+ gem "mini_racer"
24
+
25
+ group :development, :test do
26
+ gem "listen"
27
+ gem "pry"
28
+ gem "pry-byebug"
29
+ gem "pry-doc"
30
+ gem "pry-rails"
31
+ gem "pry-rescue"
32
+ gem "rubocop", require: false
33
+ gem "rubocop-performance", require: false
34
+ gem "rubocop-rspec", require: false
35
+ gem "scss_lint", require: false
36
+ gem "spring"
37
+ end
38
+
39
+ group :test do
40
+ gem "capybara"
41
+ gem "capybara-screenshot"
42
+ gem "coveralls", require: false
43
+ gem "equivalent-xml"
44
+ gem "generator_spec"
45
+ gem "launchy"
46
+ gem "rspec_junit_formatter"
47
+ gem "rspec-rails"
48
+ gem "rspec-retry"
49
+ gem "selenium-webdriver"
50
+ gem "webdrivers", "3.9.4"
51
+ end
data/NEWS.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  *We'll keep a history of the news. A few bullets at the top will also show on the [README.md](./README.md).*
4
4
 
5
+ * July 8, 2020: Release **v12**.
6
+ 1. **React Hooks Support** for top level components
7
+ 2. **Typescript bindings**
8
+ 3. **rails/webpacker** "just works" with React on Rails by default.
9
+ 4. i18n support for generating a JSON file rather than a JS file.
5
10
  * 2018-02-27: **Version 10.1.2** Supports the React API for ReactDOM.hydrate.
6
11
  * 2017-09-06: **VERSION 9.0.0 shipped!** This version depends on Webpacker directly. See [Upgrading React on Rails](./docs/basics/upgrading-react-on-rails.md) for more concise instructions on upgrading.
7
12
  * Always see the [CHANGELOG.md](./CHANGELOG.md) for the latest project changes.
data/README.md CHANGED
@@ -3,17 +3,25 @@
3
3
  <p align="center">
4
4
  <a href="https://shakacode.com/"><img src="https://user-images.githubusercontent.com/10421828/79436256-517d0500-7fd9-11ea-9300-dfbc7c293f26.png"></a>
5
5
  <a href="https://forum.shakacode.com/"><img src="https://user-images.githubusercontent.com/10421828/79436266-53df5f00-7fd9-11ea-94b3-b985e1b05bdc.png"></a>
6
- <a href="https://forum.shakacode.com/t/react-on-rails-pro-2020-shave-the-yak/1842"><img src="https://user-images.githubusercontent.com/10421828/79436265-53df5f00-7fd9-11ea-8220-fc474f6a856c.png"></a>
6
+ <a href="https://www.shakacode.com/react-on-rails-pro"><img src="https://user-images.githubusercontent.com/10421828/79436265-53df5f00-7fd9-11ea-8220-fc474f6a856c.png"></a>
7
7
  <a href="https://github.com/sponsors/shakacode"><img src="https://user-images.githubusercontent.com/10421828/79466109-cdd90d80-8004-11ea-88e5-25f9a9ddcf44.png"></a>
8
8
  </p>
9
9
 
10
10
  ---
11
11
 
12
- [![License](https://img.shields.io/badge/license-mit-green.svg)](./LICENSE.md) [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Gem Version](https://badge.fury.io/rb/react_on_rails.svg)](https://badge.fury.io/rb/react_on_rails) [![npm version](https://badge.fury.io/js/react-on-rails.svg)](https://badge.fury.io/js/react-on-rails) [![Code Climate](https://codeclimate.com/github/shakacode/react_on_rails/badges/gpa.svg)](https://codeclimate.com/github/shakacode/react_on_rails) [![Coverage Status](https://coveralls.io/repos/shakacode/react_on_rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/shakacode/react_on_rails?branch=master) [![](https://ruby-gem-downloads-badge.herokuapp.com/react_on_rails?type=total)](https://rubygems.org/gems/react_on_rails)
12
+ [![License](https://img.shields.io/badge/license-mit-green.svg)](LICENSE.md) [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Gem Version](https://badge.fury.io/rb/react_on_rails.svg)](https://badge.fury.io/rb/react_on_rails) [![npm version](https://badge.fury.io/js/react-on-rails.svg)](https://badge.fury.io/js/react-on-rails) [![Code Climate](https://codeclimate.com/github/shakacode/react_on_rails/badges/gpa.svg)](https://codeclimate.com/github/shakacode/react_on_rails) [![Coverage Status](https://coveralls.io/repos/shakacode/react_on_rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/shakacode/react_on_rails?branch=master) [![](https://ruby-gem-downloads-badge.herokuapp.com/react_on_rails?type=total)](https://rubygems.org/gems/react_on_rails)
13
13
 
14
14
  *These are the docs for React on Rails 12. To see the version 11 docs, [click here](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
15
15
 
16
16
  #### News
17
+ **October 14, 2020**: [RUBY ROGUES
18
+ RR 474: React on Rails V12 – Don’t Shave That Yak! with Justin Gordon](https://devchat.tv/ruby-rogues/rr-474-react-on-rails-v12-dont-shave-that-yak-with-justin-gordon/).
19
+
20
+ **October 1, 2020**: See the [spec/dummy](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy) example repo for a simple configuration of webpack via the rails/webpacker gem
21
+ that supports SSR.
22
+
23
+ **August 2, 2020**: See the example repo of [React on Rails Tutorial With SSR, HMR fast refresh, and TypeScript](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh) for a new way to setup the creation of your SSR bundle with `rails/webpacker`.
24
+
17
25
  **July 8, 2020**: Release v12 of React on Rails.
18
26
 
19
27
  **Major Improvements**
@@ -22,24 +30,22 @@
22
30
  2. **Typescript bindings**
23
31
  3. **rails/webpacker** "just works" with React on Rails by default.
24
32
  4. i18n support for generating a JSON file rather than a JS file.
25
-
26
- Be sure to see the [CHANGELOG.md](./CHANGELOG.md) and read the upgrade instructions:
27
- [docs/basics/upgrading-react-on-rails](./docs/basics/upgrading-react-on-rails.md#upgrading-to-v12).
28
-
33
+
34
+ Be sure to see the [CHANGELOG.md](https://github.com/shakacode/react_on_rails/tree/master/CHANGELOG.md) and read the upgrade instructions:
35
+ [docs/basics/upgrading-react-on-rails](https://www.shakacode.com/react-on-rails/docs/basics/upgrading-react-on-rails#upgrading-to-v12).
36
+
29
37
  * See Justin's RailsConf talk: [Webpacker, It-Just-Works, But How?](http://railsconf.com/2020/video/justin-gordon-webpacker-it-just-works-but-how).
30
- * Are you interested in support for React on Rails? If so check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
38
+ * Are you interested in support for React on Rails? Do you want to use Node.js to do your server-side rendering so libraries like Emotion and Loadable Components just work, as compared to rendering via Ruby embedded JS? If so check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
31
39
  * HMR is working with [Loadable Components](https://loadable-components.com) for a both amazing hot-reloading developer experience and great runtime performance. Please [email me](mailto:justin@shakacode.com) if you'd like to use [Loadable Components Code Splitting](https://loadable-components.com/docs/code-splitting/) to speed up your app by reducing your bundle sizes and lazily loading the code that's needed.
32
- * `react_on_rails` fully supports `rails/webpacker`. The example test app in `spec/dummy` was recently converted over to use rails/webpacker v4+. It's a good example of how to leverage rails/webpacker's webpack configuration.
33
-
34
40
  ---
35
41
 
36
42
  #### About
37
43
  React on Rails integrates Rails with (server rendering of) Facebook's [React](https://github.com/facebook/react) front-end framework.
38
44
 
39
- This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com). We focus on React front-ends, often with Ruby on Rails or Gatsby, using TypeScript or ReasonML. The best way to see what we do is to see the details of [our recent work](https://www.shakacode.com/recent-work).
45
+ This project is maintained by the software consulting firm [ShakaCode](https://www.shakacode.com). We focus on Ruby on Rails applications with React front-ends, often using TypeScript or ReasonML. We also build Gatsby sites. See [our recent work](https://www.shakacode.com/recent-work) for examples of what we do.
40
46
 
41
47
  Interested in optimizing your webpack setup for React on Rails including code
42
- splitting with [react-router](https://github.com/ReactTraining/react-router#readme),
48
+ splitting with [react-router](https://github.com/ReactTraining/react-router#readme),
43
49
  and [loadable-components](https://loadable-components.com/) with server-side rendering?
44
50
  We just did this for Popmenu, [lowering Heroku costs 20-25% while getting a 73% decrease in average response times](https://www.shakacode.com/recent-work/popmenu/).
45
51
 
@@ -55,28 +61,31 @@ To provide a high performance framework for integrating Ruby on Rails with React
55
61
 
56
62
  ## Features and Why React on Rails?
57
63
 
58
- Given that `rails/webpacker` gem already provides basic React integration, why would you use "React on Rails"?
64
+ Given that `rails/webpacker` gem already provides basic React integration, why would you use "React on Rails"?
59
65
 
60
66
  1. Easy passing of props directly from your Rails view to your React components rather than having your Rails view load and then make a separate request to your API.
61
67
  1. Tight integration with [rails/webpacker](https://github.com/rails/webpacker).
62
68
  1. Server-Side Rendering (SSR), often used for SEO crawler indexing and UX performance, is not offered by `rails/webpacker`.
63
69
  1. [Redux](https://github.com/reactjs/redux) and [React Router](https://github.com/ReactTraining/react-router#readme) integration with server-side-rendering.
64
- 1. [Internationalization (I18n) and (localization)](https://github.com/shakacode/react_on_rails/blob/master/docs/basics/i18n.md)
65
- 1. A supportive community. This [web search shows how live public sites are using React on Rails](https://publicwww.com/websites/%22react-on-rails%22++-undeveloped.com/).
70
+ 1. [Internationalization (I18n) and (localization)](https://www.shakacode.com/react-on-rails/docs/basics/i18n)
71
+ 1. A supportive community. This [web search shows how live public sites are using React on Rails](https://publicwww.com/websites/%22react-on-rails%22++-undeveloped.com+depth%3Aall/).
66
72
  1. [Reason ML Support](https://github.com/shakacode/reason-react-on-rails-example).
67
73
 
74
+ See [Rails/Webpacker React Integration Options](./docs/rails-webpacker-react-integration-options.md) for comparisons to other gems.
75
+
68
76
  See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
69
77
 
70
78
  ## ShakaCode Forum Premium Content
71
79
  _Requires creating a free account._
72
-
80
+
73
81
  * [How to use different versions of a file for client and server rendering](https://forum.shakacode.com/t/how-to-use-different-versions-of-a-file-for-client-and-server-rendering/1352)
82
+ * [How to conditionally render server side based on the device type](https://forum.shakacode.com/t/how-to-conditionally-render-server-side-based-on-the-device-type/1473)
74
83
 
75
84
  ----
76
85
 
77
86
  # Docs
78
87
 
79
- **Consider browsing this on our [documentation Gitbook](https://shakacode.gitbooks.io/react-on-rails/content/).**
88
+ **Consider browsing this on our [website](https://www.shakacode.com/react-on-rails/docs/).**
80
89
 
81
90
  ## Prerequisites
82
91
 
@@ -84,16 +93,16 @@ Ruby on Rails >=5 and rails/webpacker 4.2+.
84
93
 
85
94
  ## Getting Started
86
95
 
87
- Note, the best way to understand how to use ReactOnRails is to study a few simple examples. You can do a quick demo setup, either on your existing app or on a new Rails app.
96
+ Note, the best way to understand how to use ReactOnRails is to study a few simple examples. You can do a quick demo setup, either on your existing app or on a new Rails app.
88
97
 
89
- 1. Do the quick [tutorial](docs/tutorial.md).
90
- 2. Add React on Rails to an existing Rails app per [the instructions](docs/basics/installation-into-an-existing-rails-app.md).
91
- 3. Look at [spec/dummy](spec/dummy), a simple, no DB example.
98
+ 1. Do the quick [tutorial](https://www.shakacode.com/react-on-rails/docs/basics/tutorial).
99
+ 2. Add React on Rails to an existing Rails app per [the instructions](https://www.shakacode.com/react-on-rails/docs/basics/installation-into-an-existing-rails-app).
100
+ 3. Look at [spec/dummy](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy), a simple, no DB example.
92
101
  3. Look at [github.com/shakacode/react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial); it's a full-featured example live at [www.reactrails.com](http://www.reactrails.com).
93
102
 
94
103
  ## Basic Installation
95
104
 
96
- *See also [the instructions for installing into an existing Rails app](docs/basics/installation-into-an-existing-rails-app.md).*
105
+ *See also [the instructions for installing into an existing Rails app](https://www.shakacode.com/react-on-rails/docs/basics/installation-into-an-existing-rails-app).*
97
106
 
98
107
  2. Add the `react_on_rails` gem to Gemfile:
99
108
 
@@ -117,7 +126,7 @@ Note, the best way to understand how to use ReactOnRails is to study a few simpl
117
126
 
118
127
  7. Visit http://localhost:3000/hello_world.
119
128
 
120
-
129
+
121
130
  ### Turning on server rendering
122
131
 
123
132
  With the code from running the React on Rails generator above:
@@ -140,8 +149,8 @@ issue.
140
149
 
141
150
  ### Configuration
142
151
 
143
- * Configure `config/initializers/react_on_rails.rb`. You can adjust some necessary settings and defaults. See file [docs/basics/configuration.md](docs/basics/configuration.md) for documentation of all configuration options.
144
- * Configure `config/webpacker.yml`. If you used the generator and the default webpacker setup, you don't need to touch this file. If you are customizing your setup, then consult the [spec/dummy/config/webpacker.yml](./spec/dummy/config/webpacker.yml) example or the official default [webpacker.yml](https://github.com/rails/webpacker/blob/master/lib/install/config/webpacker.yml).
152
+ * Configure `config/initializers/react_on_rails.rb`. You can adjust some necessary settings and defaults. See file [docs/basics/configuration.md](https://www.shakacode.com/react-on-rails/docs/basics/configuration) for documentation of all configuration options.
153
+ * Configure `config/webpacker.yml`. If you used the generator and the default webpacker setup, you don't need to touch this file. If you are customizing your setup, then consult the [spec/dummy/config/webpacker.yml](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/webpacker.yml) example or the official default [webpacker.yml](https://github.com/rails/webpacker/blob/master/lib/install/config/webpacker.yml).
145
154
  * Tip: set `compile: false` for development if you know that you'll always be compiling with a watch process. Otherwise, every request will check if compilation is needed.
146
155
  * Your `public_output_path` must match your custom Webpack configuration for `output` of your bundles.
147
156
  * Only set `cache_manifest` to `true` in your production env.
@@ -176,9 +185,9 @@ issue.
176
185
  # Rails View
177
186
  <%= react_component("HelloWorld", props: { name: "Stranger" }) %>
178
187
  ```
179
-
180
- - This is what your HelloWorld.js file might contain. The railsContext is always available for any parameters that you _always_ want available for your React components. It has _nothing_ to do with the concept of the [React Context](https://reactjs.org/docs/context.html). See [Render-Functions and the RailsContext](docs/basics/render-functions-and-railscontext.md) for more details on this topic.
181
-
188
+
189
+ - This is what your HelloWorld.js file might contain. The railsContext is always available for any parameters that you _always_ want available for your React components. It has _nothing_ to do with the concept of the [React Context](https://reactjs.org/docs/context.html). See [Render-Functions and the RailsContext](https://www.shakacode.com/react-on-rails/docs/basics/render-functions-and-railscontext) for more details on this topic.
190
+
182
191
  ```js
183
192
  import React from 'react';
184
193
 
@@ -191,9 +200,9 @@ issue.
191
200
  </div>
192
201
  );
193
202
  };
194
- ```
195
-
196
- See the [View Helpers API](./docs/api/view-helpers-api.md) for more details on `react_component` and its sibling function `react_component_hash`.
203
+ ```
204
+
205
+ See the [View Helpers API](https://www.shakacode.com/react-on-rails/docs/api/view-helpers-api) for more details on `react_component` and its sibling function `react_component_hash`.
197
206
 
198
207
  ## Globally Exposing Your React Components
199
208
 
@@ -212,7 +221,7 @@ This is how to expose a component to the `react_component` view helper.
212
221
 
213
222
  #### Different Server-Side Rendering Code (and a Server-Specific Bundle)
214
223
 
215
- You may want different code for your server-rendered components running server side versus client side. For example, if you have an animation that runs when a component is displayed, you might need to turn that off when server rendering. One way to handle this is conditional code like `if (window) { doClientOnlyCode() }`.
224
+ You may want different code for your server-rendered components running server side versus client side. For example, if you have an animation that runs when a component is displayed, you might need to turn that off when server rendering. One way to handle this is conditional code like `if (window) { doClientOnlyCode() }`.
216
225
 
217
226
  Another way is to use a separate webpack configuration file that can use a different server side entry file, like 'serverRegistration.js' as opposed to 'clientRegistration.js.' That would set up different code for server rendering.
218
227
 
@@ -222,7 +231,7 @@ For details on techniques to use different code for client and server rendering,
222
231
 
223
232
  You have two ways to specify your React components. You can either register the React component (either function or class component) directly, or you can create a function that returns a React component, which we using the name of a "render-function". Creating a render-function allows:
224
233
 
225
- 1. You to have access to the `railsContext`. See [documentation for the railsContext](./docs/basics/render-functions-and-railscontext.md) in terms of why you might need it. You **need** a Render-Function to access the `railsContext`.
234
+ 1. You to have access to the `railsContext`. See [documentation for the railsContext](https://www.shakacode.com/react-on-rails/docs/basics/render-functions-and-railscontext) in terms of why you might need it. You **need** a Render-Function to access the `railsContext`.
226
235
  2. You can use the passed-in props to initialize a redux store or set up react-router.
227
236
  3. You can return different components depending on what's in the props.
228
237
 
@@ -248,7 +257,7 @@ Thus, there is no difference between registering a React Function Component or c
248
257
 
249
258
  ## react_component_hash for Render-Functions
250
259
 
251
- Another reason to use a Render-Function is that sometimes in server rendering, specifically with React Router, you need to return the result of calling ReactDOMServer.renderToString(element). You can do this by returning an object with the following shape: { renderedHtml, redirectLocation, error }. Make sure you use this function with `react_component_hash`.
260
+ Another reason to use a Render-Function is that sometimes in server rendering, specifically with React Router, you need to return the result of calling ReactDOMServer.renderToString(element). You can do this by returning an object with the following shape: { renderedHtml, redirectLocation, error }. Make sure you use this function with `react_component_hash`.
252
261
 
253
262
  For server rendering, if you wish to return multiple HTML strings from a Render-Function, you may return an Object from your Render-Function with a single top-level property of `renderedHtml`. Inside this Object, place a key called `componentHtml`, along with any other needed keys. An example scenario of this is when you are using side effects libraries like [React Helmet](https://github.com/nfl/react-helmet). Your Ruby code will get this Object as a Hash containing keys componentHtml and any other custom keys that you added:
254
263
 
@@ -256,7 +265,7 @@ For server rendering, if you wish to return multiple HTML strings from a Render-
256
265
  { renderedHtml: { componentHtml, customKey1, customKey2} }
257
266
  ```
258
267
 
259
- For details on using react_component_hash with react-helmet, see the docs below for the helper API and [docs/additional-reading/react-helmet.md](docs/additional-reading/react-helmet.md).
268
+ For details on using react_component_hash with react-helmet, see [our react-helmet documentation](https://www.shakacode.com/react-on-rails/docs/additional-reading/react-helmet).
260
269
 
261
270
  ## Error Handling
262
271
 
@@ -266,20 +275,19 @@ For details on using react_component_hash with react-helmet, see the docs below
266
275
  ## I18n
267
276
 
268
277
  React on Rails provides an option for automatic conversions of Rails `*.yml` locale files into `*.json` or `*.js*.
269
- See the [How to add I18n](docs/basics/i18n.md) for a summary of adding I18n.
278
+ See the [How to add I18n](https://www.shakacode.com/react-on-rails/docs/basics/i18n) for a summary of adding I18n.
270
279
 
271
280
  ## More Details
272
281
 
273
- Browse the links in the [Summary Table of Contents](./SUMMARY.md)
282
+ Browse the links in the [Summary Table of Contents](https://github.com/shakacode/react_on_rails/tree/master/SUMMARY.md)
274
283
 
275
284
  Here are some highly recommended next articles to read:
276
285
 
277
- 1. [How React on Rails Works](docs/outdated/how-react-on-rails-works.md)
278
- 1. [Recommended Project Structure](./docs/basics/recommended-project-structure.md)
279
- 1. [Webpack Configuration](./docs/basics/webpack-configuration.md)
280
- 1. [View Helpers API](./docs/api/view-helpers-api.md)
286
+ 1. [How React on Rails Works](https://www.shakacode.com/react-on-rails/docs/basics/how-react-on-rails-works)
287
+ 1. [Webpack Configuration](https://www.shakacode.com/react-on-rails/docs/basics/webpack-configuration)
288
+ 1. [View Helpers API](https://www.shakacode.com/react-on-rails/docs/api/view-helpers-api)
281
289
  1. [Caching and Performance: React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
282
- 1. [Deployment](docs/basics/deployment.md).
290
+ 1. [Deployment](https://www.shakacode.com/react-on-rails/docs/basics/deployment).
283
291
 
284
292
  # Support
285
293
 
@@ -295,20 +303,20 @@ Please [**click to subscribe**](https://app.mailerlite.com/webforms/landing/l1d9
295
303
  - **[forum.shakacode.com](https://forum.shakacode.com)**: Post your questions
296
304
  - **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
297
305
  - For a live, [open source](https://github.com/shakacode/react-webpack-rails-tutorial), example of this gem, see [www.reactrails.com](http://www.reactrails.com).
298
- - See [Projects](PROJECTS.md) using and [KUDOS](./KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:contact@shakacode.com) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
299
- - *See [NEWS.md](NEWS.md) for more notes over time.*
306
+ - See [Projects](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) using and [KUDOS](https://github.com/shakacode/react_on_rails/tree/master/KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:contact@shakacode.com) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
307
+ - *See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time.*
300
308
 
301
309
  ## Contributing
302
310
 
303
- Bug reports and pull requests are welcome. See [Contributing](CONTRIBUTING.md) to get started, and the [list of help wanted issues](https://github.com/shakacode/react_on_rails/labels/contributions%3A%20up%20for%20grabs%21).
311
+ Bug reports and pull requests are welcome. See [Contributing](https://github.com/shakacode/react_on_rails/tree/master/CONTRIBUTING.md) to get started, and the [list of help wanted issues](https://github.com/shakacode/react_on_rails/labels/contributions%3A%20up%20for%20grabs%21).
304
312
 
305
313
  ## React on Rails Pro
306
314
 
307
- React on Rails Pro provides Node server rendering, fragment caching, code-splitting, and other performance enhancements for React on Rails. For a case study, see the article [HVMN’s 90% Reduction in Server Response Time from React on Rails Pro](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db). The [Wiki](https://github.com/shakacode/react_on_rails/wiki) contains more details.
315
+ Support React on Rails Pro development [by becoming a Github sponsor](https://github.com/sponsors/shakacode) and get these benefits.
308
316
 
309
- [![2018-09-11_10-31-11](https://user-images.githubusercontent.com/1118459/45467845-5bcc7400-b6bd-11e8-91e1-e0cf806d4ea4.png)](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db)
317
+ React on Rails Pro includes Node server rendering, fragment caching, code-splitting, and other performance enhancements for React on Rails. For a case study, see the article [HVMN’s 90% Reduction in Server Response Time from React on Rails Pro](https://www.shakacode.com/blog/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro/). The [Wiki](https://github.com/shakacode/react_on_rails/wiki) contains more details.
310
318
 
311
- ## React on Rails Pro Support
319
+ [![2018-09-11_10-31-11](https://user-images.githubusercontent.com/1118459/45467845-5bcc7400-b6bd-11e8-91e1-e0cf806d4ea4.png)](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db)
312
320
 
313
321
  The [React on Rails Pro Support Plan](https://www.shakacode.com/react-on-rails-pro) can help!
314
322
 
@@ -322,7 +330,7 @@ ShakaCode can also help you with your custom software development needs. We spec
322
330
 
323
331
  Please email Justin Gordon [justin@shakacode.com](mailto:justin@shakacode.com), the maintainer of React on Rails, for more information.
324
332
 
325
- ### Fragment Caching
333
+ ### Pro: Fragment Caching
326
334
 
327
335
  Fragment caching is a [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro) feature. Fragment caching is a **HUGE** performance booster for your apps. Use the `cached_react_component` and `cached_react_component_hash`. The API is the same as `react_component` and `react_component_hash`, but for 2 differences:
328
336
 
@@ -343,16 +351,16 @@ Such fragment caching saves CPU work for your web server and greatly reduces the
343
351
  4. Creating the HTML string containing the props and the server-rendered JavaScript code.
344
352
 
345
353
  Note, even without server rendering (without step 3 above), fragment caching is still effective.
346
-
347
- ## Integration with Node.js for Server Rendering
354
+
355
+ ### Pro: Integration with Node.js for Server Rendering
348
356
 
349
357
  Default server rendering is done by ExecJS. If you want to use a Node.js server for better performing server rendering, [email justin@shakacode.com](mailto:justin@shakacode.com). ShakaCode has built a premium Node rendering server that is part of [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
350
358
 
351
359
  ## Testimonials for ShakaCode
352
- [HVMN Testimonial, by Paul Benigeri, October 12, 2018](./docs/testimonials/hvmn.md)
360
+ [HVMN Testimonial, by Paul Benigeri, October 12, 2018](https://www.shakacode.com/react-on-rails/docs/testimonials/hvmn)
353
361
  > The price we paid for the consultation + the React on Rails pro license has already been made back a couple of times from hosting fees alone. The entire process was super hands off, and our core team was able to focus on shipping new feature during that sprint.
354
362
 
355
- [ResortPass Testimonial, by Leora Juster, December 10, 2018](./docs/testimonials/resortpass.md)
363
+ [ResortPass Testimonial, by Leora Juster, December 10, 2018](https://www.shakacode.com/react-on-rails/docs/testimonials/resortpass)
356
364
 
357
365
  > Justin and his team were instrumental in assisting us in setting design foundations and standards for our transition to a react on rails application. Just three months of work with the team at Shaka code and we have a main page of our application server-side rendering at exponentially improved speeds.
358
366
 
@@ -360,16 +368,17 @@ From Joel Hooks, Co-Founder, Chief Nerd at [egghead.io](https://egghead.io/), Ja
360
368
 
361
369
  ![2017-01-30_11-33-59](https://cloud.githubusercontent.com/assets/1118459/22443635/b3549fb4-e6e3-11e6-8ea2-6f589dc93ed3.png)
362
370
 
363
- For more testimonials, see [Live Projects](PROJECTS.md) and [Kudos](./KUDOS.md).
371
+ For more testimonials, see [Live Projects](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) and [Kudos](https://github.com/shakacode/react_on_rails/tree/master/KUDOS.md).
364
372
 
365
373
  # Supporters
366
374
 
367
- The following companies support this open source project, and ShakaCode uses their products! Justin writes React on Rails on [RubyMine](https://www.jetbrains.com/ruby/). We use [Scout](https://scoutapp.com/) to monitor the live performance of [HawaiiChee.com](https://www.hawaiichee.com), [BrowserStack](https://www.browserstack.com) to solve problems with oddball browsers, and [CodersRank](https://codersrank.io/) to find candidates for our team.
375
+ The following companies support this open source project, and ShakaCode uses their products! Justin writes React on Rails on [RubyMine](https://www.jetbrains.com/ruby/). We use [Scout](https://scoutapp.com/) to monitor the live performance of [HiChee.com](https://HiChee.com), [Rails AutoScale](https://railsautoscale.com) to scale the dynos of HiChee, [BrowserStack](https://www.browserstack.com) to solve problems with oddball browsers.
368
376
 
369
377
  [![2019-09-24_17-48-00](https://user-images.githubusercontent.com/1118459/65567887-96353780-def3-11e9-926d-4a55e2e186ff.png)](https://www.jetbrains.com/ruby/)
370
378
  [![Scout](https://user-images.githubusercontent.com/1118459/41828269-106b40f8-77d0-11e8-8d19-9c4b167ef9d8.png)](https://scoutapp.com/)
379
+ [![2020-12-27_21-26-19](https://user-images.githubusercontent.com/1118459/103197530-48dc0e80-488a-11eb-8b1b-a16664b30274.png)](https://railsautoscale.com/)
371
380
  [![BrowserStack](https://cloud.githubusercontent.com/assets/1118459/23203304/1261e468-f886-11e6-819e-93b1a3f17da4.png)](https://www.browserstack.com)
372
- [![CodersRank](https://user-images.githubusercontent.com/1118459/55040254-ad8a7b00-4fcb-11e9-8936-c6765eb30698.png)](https://codersrank.io/?utm_source=github&utm_medium=banner&utm_campaign=shakacode)
381
+
373
382
 
374
383
  ## Clubhouse
375
384
  I've just moved ShakaCode's development to [ClubHouse](https://clubhouse.io/) from Trello. We're going to be doing this with all our projects. If you want to **try ClubHouse and get 2 months free beyond the 14-day trial period**, click [here to use ShakaCode's referral code](http://r.clbh.se/mvfoNeH). We're participating in their awesome triple-sided referral program, which you can read about [here](https://clubhouse.io/blog/clubhouse-referral-program-5f614bb437c3). By using our [referral code](http://r.clbh.se/mvfoNeH) you'll be supporting ShakaCode and, thus, React on Rails!
@@ -379,8 +388,8 @@ I've just moved ShakaCode's development to [ClubHouse](https://clubhouse.io/) fr
379
388
  Aloha and best wishes from Justin and the ShakaCode team!
380
389
 
381
390
  # Work with Us
382
- ShakaCode is **[currently looking to hire](http://www.shakacode.com/about/#work-with-us)** like-minded, remote-first, developers that wish to work on our projects, including [Hawaii Chee](https://www.hawaiichee.com). Your main coding interview will be pairing with us on our open source! We're also using [ReasonML](https://reasonml.github.io/) extensively!
391
+ ShakaCode is **[currently looking to hire](http://www.shakacode.com/about/#work-with-us)** like-minded, remote-first, developers that wish to work on our projects, including [HiChee](https://hichee.com). Your main coding interview will be pairing with us on our open source! We're also using [ReasonML](https://reasonml.github.io/) extensively!
383
392
 
384
393
  # License
385
394
 
386
- The gem is available as open source under the terms of the [MIT License](LICENSE.md).
395
+ The gem is available as open source under the terms of the [MIT License](https://github.com/shakacode/react_on_rails/tree/master/LICENSE.md).
data/SUMMARY.md CHANGED
@@ -8,7 +8,6 @@
8
8
  + [How React on Rails Works](docs/outdated/how-react-on-rails-works.md)
9
9
  + [Client vs. Server Rendering](./docs/basics/client-vs-server-rendering.md)
10
10
  + [React Server Rendering](./docs/basics/react-server-rendering.md)
11
- + [Recommended Project Structure](./docs/basics/recommended-project-structure.md)
12
11
  + [Render-Functions and the RailsContext](docs/basics/render-functions-and-railscontext.md)
13
12
  + [Caching and Performance: React on Rails Pro](https://github.com/shakacode/react_on_rails/wiki).
14
13
  + [Deployment](docs/basics/deployment.md).
@@ -28,6 +27,7 @@
28
27
  + [Updating Dependencies](./docs/additional-reading/updating-dependencies.md)
29
28
  + [Manual Installation Overview](docs/outdated/manual-installation-overview.md)
30
29
  + [Upgrading from rails/webpacker v3 to v4](docs/additional-reading/upgrade-webpacker-v3-to-v4.md)
30
+ + [Recommended Project Structure](docs/additional-reading/recommended-project-structure.md)
31
31
 
32
32
  ## **Rails**
33
33
  + [Rails Engine Integration](./docs/additional-reading/rails-engine-integration.md)
@@ -35,13 +35,9 @@ can pass the redux option if you'd like to have redux setup for you automaticall
35
35
  Then you may run
36
36
 
37
37
  `rails s`
38
-
39
- More Details:
40
-
41
- `https://github.com/shakacode/react_on_rails/blob/master/docs/basics/generator-details.md`
42
38
  ```
43
39
 
44
- Another good option is to create a simple test app per the [Tutorial](../tutorial.md).
40
+ Another good option is to create a simple test app per the [Tutorial](https://www.shakacode.com/react-on-rails/docs/basics/tutorial).
45
41
 
46
42
  # Understanding the Organization of the Generated Client Code
47
43
  The generated client code follows our organization scheme. Each unique set of functionality, is given its own folder inside of `app/javascript/app/bundles`. Note, the recommended for bigger projects is `client/app/bundles`. This encourages for modularity of *domains*.
@@ -58,4 +54,3 @@ You may also notice the `app/lib` folder. This is for any code that is common be
58
54
  If you have used the `--redux` generator option, you will notice the familiar additional redux folders in addition to the aforementioned folders. The Hello World example has also been modified to use Redux.
59
55
 
60
56
  Note the organizational paradigm of "bundles". These are like application domains and are used for grouping your code into webpack bundles, in case you decide to create different bundles for deployment. This is also useful for separating out logical parts of your application. The concept is that each bundle will have it's own Redux store. If you have code that you want to reuse across bundles, including components and reducers, place them under `/client/app/lib`.
61
-
@@ -14,17 +14,17 @@ The only requirements within this directory for basic React on Rails integration
14
14
  1. Your webpack configuration files:
15
15
  1. Create outputs in a directory like `/public/webpack`, which is customizable in your `config/initializers/react_on_rails.rb`.
16
16
  1. Provide server rendering if you wish to use that feature.
17
- 1. Your JavaScript code "registers" any components and stores per the ReactOnRails APIs of ReactOnRails.register(components) and ReactOnRails.registerStore(stores). See API docs in [README.md](README.md) and the [ReactOnRails.js source](../../node_package/src/ReactOnRails.js).
17
+ 1. Your JavaScript code "registers" any components and stores per the ReactOnRails APIs of ReactOnRails.register(components) and ReactOnRails.registerStore(stores). See [our javascript API docs](https://www.shakacode.com/react-on-rails/docs/api/javascript-api) and the [ReactOnRails.js source](https://github.com/shakacode/react_on_rails/tree/master/node_package/src/ReactOnRails.js).
18
18
  1. Set your registration file as an "entry" point in your Webpack configs.
19
- 1. Add the [Manifest plugin](https://github.com/danethurber/webpack-manifest-plugin) to your config. For examples see [dummy config](../../spec/dummy/client/webpack.client.base.config.js).
19
+ 1. Add the [Manifest plugin](https://github.com/danethurber/webpack-manifest-plugin) to your config.
20
20
  The default path: `public/webpack` can be loaded with webpackConfigLoader as shown in the dummy example.
21
21
  1. You create scripts in `client/package.json` per the example apps. These are used for building your Webpack assets. Also do this for your top level `package.json`.
22
22
 
23
23
  ## Rails Steps (outside of /client)
24
- 1. Add `gem "webpacker"` to the Gemfile, run bundle. The gem provides the `stylesheet_pack_tag` and `javascript_pack_tag` helpers which is used to load the bundled assets to your layouts.[Dummy Example](spec/dummy/app/views/layouts/application.html.erb)
25
- 1. Configure the `config/initializers/react_on_rails.rb`. You can adjust some necessary settings and defaults. See file [spec/dummy/config/initializers/react_on_rails.rb](spec/dummy/config/initializers/react_on_rails.rb) for a detailed example of configuration, including comments on the different values to configure.
24
+ 1. Add `gem "webpacker"` to the Gemfile, run bundle. The gem provides the `stylesheet_pack_tag` and `javascript_pack_tag` helpers which is used to load the bundled assets to your layouts.[Dummy Example](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/app/views/layouts/application.html.erb)
25
+ 1. Configure the `config/initializers/react_on_rails.rb`. You can adjust some necessary settings and defaults. See file [https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/initializers/react_on_rails.rb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/initializers/react_on_rails.rb) for a detailed example of configuration, including comments on the different values to configure.
26
26
  1. Configure your Procfiles per the example apps. These are at the root of your Rails installation.
27
- 1. Configure your top level JavaScript files for inclusion in your layout. You'll want a version that you use for static assets, and you want a file for any files in your setup that are not part of your webpack build. The reason for this is for use with hot-reloading. If you are not using hot reloading, then you only need to configure your `application.js` file to include your Webpack generated files.
28
- 1. If you are deploying to Heroku, see [heroku-deployment.md](/docs/basics/heroku-deployment.md)
27
+ 1. Configure your top level JavaScript files for inclusion in your layout. You'll want a version that you use for static assets, and you want a file for any files in your setup that are not part of your webpack build. The reason for this is for use with hot-reloading. If you are not using hot reloading, then you only need to configure your `application.js` file to include your Webpack generated files.
28
+ 1. If you are deploying to Heroku, see [our heroku deployment documentation](https://www.shakacode.com/react-on-rails/docs/deployment/heroku-deployment)
29
29
 
30
30
  If I missed anything, please submit a PR or file an issue.
@@ -0,0 +1,69 @@
1
+ # Recommended Project structure
2
+
3
+ The React on Rails generator uses the standard `rails/webpacker` convention of this structure:
4
+
5
+ ```yml
6
+ app/javascript:
7
+ ├── bundles:
8
+ │ # Logical groups of files that can be used for code splitting
9
+ │ └── hello-world-bundle.js
10
+ ├── packs:
11
+ │ # only webpack entry files here
12
+ │ └── hello-world-bundle.js
13
+ ```
14
+
15
+ Per the example repo [shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh),
16
+ you should consider keeping your codebase mostly consistent with the defaults for [rails/webpacker](https://github.com/rails/webpacker).
17
+
18
+ ## Steps to convert from the generator defaults to use a `/client` directory for source code
19
+
20
+ 1. Move the directory:
21
+
22
+ ```
23
+ mv app/javascript client
24
+ ```
25
+
26
+ 2. Edit your `/config/webpacker.yml` file. Change the `default/source_path`:
27
+
28
+ ```yml
29
+ source_path: client
30
+ ```
31
+
32
+ ## Moving node_modules from `/` to `/client` with a custom webpack setup.
33
+
34
+ `rails/webpacker` probably doesn't support having your main node_modules directory under `/client`, so only follow these steps if you want to use your own webpack configuration.
35
+
36
+ 1. Move the `/package.json` to `/client/package.json`
37
+ 2. Create a `/package.json` that delegates to `/client/package.json`.
38
+ ```
39
+ "scripts": {
40
+ "heroku-postbuild": "cd ./client && yarn"
41
+ },
42
+ ```
43
+ 3. If your node_modules directory is not at the top level of the Rails project, then you will need to set the
44
+ ENV value of WEBPACKER_CONFIG to the location of the `config/webpacker.yml` file per [rails/webpacker PR 2561](https://github.com/rails/webpacker/pull/2561).
45
+
46
+ ## CSS, Sass, Fonts, and Images
47
+ Should you move your styling assets to Webpack? Or stick with the plain Rails asset pipeline. It depends!
48
+
49
+ Here's a good discussion of this option: [Why does Rails 6 include both Webpacker and Sprockets?](https://rossta.net/blog/why-does-rails-install-both-webpacker-and-sprockets.html).
50
+
51
+ You have 2 basic choices:
52
+
53
+ ### Simple Rails Way
54
+ This isn't really any technique, as you keep handling all your styling assets using Rails standard tools, such as using the [sass-rails gem](https://rubygems.org/gems/sass-rails/versions/5.0.4). Basically, Webpack doesn't get involved with styling. Your Rails layouts just doing the styling the standard Rails way.
55
+
56
+ #### Advantages to the Simple Rails Way
57
+ 1. Much simpler! There's no changes really from your current processes.
58
+
59
+ ### Using Webpack to Manage Styling Assets
60
+ This technique involves customization of the webpack config files to generate CSS, image, and font assets.
61
+
62
+ #### Directory structure
63
+ 1. `/client/app/assets`: Assets for CSS for client app.
64
+ 1. `/client/app/assets/fonts` and `/client/app/assets/styles`: Globally shared assets for styling. Note, most Sass and image assets will be stored next to the JavaScript files.
65
+
66
+ #### Advantages to having Webpack Manage Styles
67
+ 1. You can use [CSS modules](https://github.com/css-modules/css-modules), which is super compelling once you seen the benefits.
68
+ 1. You can use CSS in JS.
69
+ 1. You can do hot reloading of your assets. Thus, you do not have to refresh your web page to see asset change, including changing styles.
@@ -0,0 +1,10 @@
1
+ # Upgrading rails/webpacker v3.5 to v4
2
+
3
+ The following steps can be followed to update a Webpacker v3.5 app to v4.
4
+
5
+ 1. Update the gem `webpacker` and the package `@rails/webpacker`
6
+ 1. Merge changes from the new default [.babelrc](https://github.com/shakacode/react_on_rails/tree/master/lib/install/config/.babelrc) to your `/.babelrc`. If you are using React, you need to add `"@babel/preset-react"`, to the list of `presets`.
7
+ 1. Copy the file [.browserslistrc](https://github.com/shakacode/react_on_rails/tree/master/lib/install/config/.browserslistrc) to `/`.
8
+ 1. Merge any differences between [config/webpacker.yml](https://github.com/shakacode/react_on_rails/tree/master/lib/install/config/webpacker.yml) and your `/config/webpacker.yml`.
9
+
10
+ Here is an [example commit of these changes](https://github.com/shakacode/react_on_rails-tutorial-v11/pull/1/files).
@@ -34,7 +34,7 @@ The best source of docs is the main [ReactOnRails.js](https://github.com/shakaco
34
34
  * Your Ruby code with get this Object as a Hash containing keys componentHtml and any other
35
35
  * custom keys that you added:
36
36
  * { renderedHtml: { componentHtml, customKey1, customKey2 } }
37
- * See the example in /docs/additional-reading/react-helmet.md
37
+ * See the example in https://www.shakacode.com/react-on-rails/docs/javascript/react-helmet
38
38
  * @param components (key is component name, value is component)
39
39
  */
40
40
  register(components)
@@ -69,7 +69,7 @@ The best source of docs is the main [ReactOnRails.js](https://github.com/shakaco
69
69
  * Allow directly calling the page loaded script in case the default events that trigger react
70
70
  * rendering are not sufficient, such as when loading JavaScript asynchronously with TurboLinks:
71
71
  * More details can be found here:
72
- * https://github.com/shakacode/react_on_rails/blob/master/docs/additional-reading/turbolinks.md
72
+ * https://www.shakacode.com/react-on-rails/docs/rails/turbolinks
73
73
  */
74
74
  reactOnRailsPageLoaded()
75
75
 
@@ -13,7 +13,7 @@ Consider using the `redux_store` helper for the two following use cases:
13
13
 
14
14
  ## Multiple React Components on a Page with One Store
15
15
 
16
- You may wish to have 2 React components share the same the Redux store. For example, if your navbar is a React component, you may want it to use the same store as your component in the main area of the page. You may even want multiple React components in the main area, which allows for greater modularity. Also, you may want this to work with Turbolinks to minimize reloading the JavaScript.
16
+ You may wish to have 2 React components share the same the Redux store. For example, if your navbar is a React component, you may want it to use the same store as your component in the main area of the page. You may even want multiple React components in the main area, which allows for greater modularity. Also, you may want this to work with Turbolinks to minimize reloading the JavaScript.
17
17
 
18
18
  A good example of this would be something like a notifications counter in a header. As each notification is read in the body of the page, you would like to update the header. If both the header and body share the same Redux store, then this is trivial. Otherwise, we have to rely on other solutions, such as the header polling the server to see how many unread notifications exist.
19
19
 
@@ -98,5 +98,5 @@ Place this view helper (no parameters) at the end of your shared layout so React
98
98
 
99
99
  # More Details
100
100
 
101
- * [lib/react_on_rails/controller.rb](../../lib/react_on_rails/controller.rb) source
102
- * [lib/react_on_rails/helper.rb](../../lib/react_on_rails/helper.rb) source
101
+ * [lib/react_on_rails/controller.rb](https://github.com/shakacode/react_on_rails/tree/master/lib/react_on_rails/controller.rb) source
102
+ * [lib/react_on_rails/helper.rb](https://github.com/shakacode/react_on_rails/tree/master/lib/react_on_rails/helper.rb) source