react_on_rails 9.0.0.beta.11 → 9.0.0.beta.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintignore +2 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.md +24 -9
- data/Gemfile +2 -2
- data/Gemfile.rails32 +74 -0
- data/README.md +17 -12
- data/Rakefile +8 -1
- data/app/helpers/react_on_rails_helper.rb +1 -1
- data/docs/additional-reading/asset-pipeline.md +20 -0
- data/docs/additional-reading/hot-reloading-rails-development.md +0 -75
- data/docs/additional-reading/rspec-configuration.md +6 -23
- data/{lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt → docs/basics/configuration.md} +78 -41
- data/docs/basics/generator.md +0 -5
- data/docs/basics/installation-overview.md +5 -4
- data/docs/tutorial.md +25 -13
- data/lib/generators/USAGE +0 -4
- data/lib/generators/react_on_rails/base_generator.rb +41 -81
- data/lib/generators/react_on_rails/dev_tests_generator.rb +7 -5
- data/lib/generators/react_on_rails/install_generator.rb +5 -10
- data/lib/generators/react_on_rails/react_no_redux_generator.rb +10 -9
- data/lib/generators/react_on_rails/react_with_redux_generator.rb +27 -17
- data/lib/generators/react_on_rails/templates/.eslintrc +2 -0
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +4 -0
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-server +5 -0
- data/lib/generators/react_on_rails/templates/base/base/{client/app → app/javascript}/bundles/HelloWorld/components/HelloWorld.jsx +0 -0
- data/lib/generators/react_on_rails/templates/base/base/{client/app/bundles/HelloWorld/startup/registration.jsx.tt → app/javascript/packs/registration.js.tt} +0 -0
- data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +0 -1
- data/lib/generators/react_on_rails/templates/base/base/app/views/layouts/{hello_world.html.erb.tt → hello_world.html.erb} +3 -3
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +41 -0
- data/lib/generators/react_on_rails/templates/dev_tests/.eslintrc +25 -0
- data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +0 -1
- data/lib/generators/react_on_rails/templates/dev_tests/spec/spec_helper.rb +2 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx → app/javascript/bundles/HelloWorld/actions/helloWorldActionCreators.js} +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app → app/javascript}/bundles/HelloWorld/components/HelloWorld.jsx +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx → app/javascript/bundles/HelloWorld/constants/helloWorldConstants.js} +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx → app/javascript/bundles/HelloWorld/containers/HelloWorldContainer.js} +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx → app/javascript/bundles/HelloWorld/reducers/helloWorldReducer.js} +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app → app/javascript}/bundles/HelloWorld/startup/HelloWorldApp.jsx +0 -0
- data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/store/helloWorldStore.jsx → app/javascript/bundles/HelloWorld/store/helloWorldStore.js} +0 -0
- data/lib/react_on_rails/configuration.rb +15 -10
- data/lib/react_on_rails/server_rendering_pool/exec.rb +21 -8
- data/lib/react_on_rails/test_helper.rb +6 -6
- data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +1 -1
- data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +3 -1
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +10 -6
- data/lib/react_on_rails/utils.rb +34 -3
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +1 -1
- data/lib/tasks/assets.rake +10 -2
- data/package.json +6 -2
- data/rakelib/dummy_apps.rake +9 -0
- data/rakelib/example_type.rb +8 -19
- data/rakelib/examples.rake +3 -5
- data/rakelib/run_rspec.rake +17 -0
- data/yarn.lock +29 -0
- metadata +19 -23
- data/lib/generators/react_on_rails/node_generator.rb +0 -24
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +0 -4
- data/lib/generators/react_on_rails/templates/base/base/client/.babelrc +0 -3
- data/lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md +0 -9
- data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +0 -36
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.config.js +0 -78
- data/lib/generators/react_on_rails/templates/base/base/config/webpacker.yml +0 -28
- data/lib/generators/react_on_rails/templates/base/base/package.json.tt +0 -8
- data/lib/generators/react_on_rails/templates/node/base/client/node/package.json +0 -10
- data/lib/generators/react_on_rails/templates/node/base/client/node/server.js +0 -105
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a99cdeb5818a06173daa27fe511864be5f3b6890
|
4
|
+
data.tar.gz: 1e8963da13595accc8eb5c1febab8e0d95c6b8d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fbd64f6e6a1535b359a503b484dd35ed967ae3327b990b13fa9a7a6ab1ca47008fcb14defa92abb3ce6ba07e42f6d3ee0eb4f1ef01c6255153bc5205fd7ae94
|
7
|
+
data.tar.gz: 03fa4ec625fe040028715c0860222fe03e3f83f061eb5b23aaac62f8184bfa9ccb4929a800f550312fdbc36d6e82d7dd89cc6fe805e4ecda08c07a20ee11a873
|
data/.eslintignore
CHANGED
@@ -2,6 +2,7 @@ node_modules
|
|
2
2
|
coverage
|
3
3
|
spec/react_on_rails/dummy-for-generators
|
4
4
|
spec/dummy
|
5
|
+
spec/dummy_no_webpacker
|
5
6
|
node_package/lib/
|
6
7
|
node_package/tests/node_modules
|
7
8
|
node_package/webpack.config.js
|
@@ -12,3 +13,4 @@ node_package/webpack.config.js
|
|
12
13
|
**/app/assets/javascripts/application.js
|
13
14
|
**/coverage/**
|
14
15
|
**/cable.js
|
16
|
+
**/public/packs*/*
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -27,6 +27,10 @@ AllCops:
|
|
27
27
|
- 'spec/dummy/bin/**/*'
|
28
28
|
- 'spec/dummy/client/node_modules/**/*'
|
29
29
|
- 'spec/dummy/client/node_modules/**/.*'
|
30
|
+
- 'spec/dummy_no_webpacker/Procfile.*'
|
31
|
+
- 'spec/dummy_no_webpacker/bin/**/*'
|
32
|
+
- 'spec/dummy_no_webpacker/client/node_modules/**/*'
|
33
|
+
- 'spec/dummy_no_webpacker/client/node_modules/**/.*'
|
30
34
|
- 'gen-examples/examples/**/.*'
|
31
35
|
- 'gen-examples/examples/**/*'
|
32
36
|
|
@@ -34,6 +38,7 @@ Style/FileName:
|
|
34
38
|
Exclude:
|
35
39
|
- 'Gemfile'
|
36
40
|
- 'spec/dummy/Gemfile'
|
41
|
+
- 'spec/dummy_no_webpacker/Gemfile'
|
37
42
|
|
38
43
|
# Turn off until we require 2.3 ruby
|
39
44
|
Style/SafeNavigation:
|
data/.travis.yml
CHANGED
@@ -6,6 +6,7 @@ rvm:
|
|
6
6
|
# Rails 5 requires 2.2
|
7
7
|
- 2.3.1
|
8
8
|
- 2.4.1
|
9
|
+
- 2.2.6
|
9
10
|
services:
|
10
11
|
- docker
|
11
12
|
|
@@ -17,6 +18,7 @@ cache:
|
|
17
18
|
|
18
19
|
gemfile:
|
19
20
|
- spec/dummy/Gemfile
|
21
|
+
- spec/dummy_no_webpacker/Gemfile.rails32
|
20
22
|
|
21
23
|
env:
|
22
24
|
global:
|
@@ -49,6 +51,15 @@ before_script:
|
|
49
51
|
script:
|
50
52
|
- bundle exec rake
|
51
53
|
|
54
|
+
matrix:
|
55
|
+
exclude:
|
56
|
+
- gemfile: spec/dummy_no_webpacker/Gemfile.rails32
|
57
|
+
rvm: 2.3.1
|
58
|
+
- gemfile: spec/dummy_no_webpacker/Gemfile.rails32
|
59
|
+
rvm: 2.4.1
|
60
|
+
- gemfile: spec/dummy/Gemfile
|
61
|
+
rvm: 2.2.6
|
62
|
+
|
52
63
|
notifications:
|
53
64
|
slack:
|
54
65
|
secure: LfcUk4AJ4vAxWwRIyw4tFh8QNbYefMwfG/oLfsN3CdRMWMOtCOHR1GGsRhAOlfVVJ/FvHqVqWj5gK7z7CaO5Uvl7rD3/zJ8QzExKx/iH9yWj55iIPuKLzwFNnBwRpFW/cqyU2lFPPRxGD50BUn3c+qybkuSqtKZ6qtTowwqlxLa5iyM3N95aZp7MEIKCP7cPcnHfLbJyP8wBpotp/rtw62eXM2HIRJJwgjcp+n+My7VFR9DnBXNFf6R91aZHM4U4cHHDbu15HFtH8honVrzK1JQdyqMNHga+j04dFuaS7z9Q369/hsELMOBp/227+Pz7ZRfWZFK4UASguOvyeX7RmGTRpTuWLm1XJeUzfsPZVROecaSVQBve+U7F12yKqilt97QlvRXn2EGyBILqvxtFNNR4S9kgAf72/6EFgiM1TKq7i9zy6lVOnagU2+7amq7UeopX1uoFsUfNKMR7YbgV1WjF0IK95UP0b0/7ZOJlPYgi5zzkQi129qAFWSMmxGk+ZpsttHh/tjJtvAh0A3mHq/zb5w4ub/MbSyZqeDUNgGj72QArOWUFSAStQT1ybsVLeDoKPgOvVq7OV1D64rpcHjBXcqOCit8tDZ+TqkFhcYJo2cITSaqE4zJXn+4F5s7So5O8CyfKYQq+kFJCooYGmfgTUckJpGl7eIvKmL4TN9Q=
|
data/CHANGELOG.md
CHANGED
@@ -14,11 +14,16 @@ Changes since last non-beta release.
|
|
14
14
|
## 9.0 from 8.x. Upgrade Instructions
|
15
15
|
All 9.0.0 beta versions can be viewed in [PR 908](https://github.com/shakacode/react_on_rails/pull/908)
|
16
16
|
|
17
|
-
-
|
17
|
+
- Breaking Configuration Changes
|
18
|
+
1. Added `config.node_modules_location` which defaults to `""` if Webpacker is installed. You may want to set this to 'client'` to `config/initializers/react_on_rails.rb` to keep your node_modules inside of `/client`
|
19
|
+
2. Renamed
|
20
|
+
* config.npm_build_test_command ==> config.build_test_command
|
21
|
+
* config.npm_build_production_command ==> config.build_production_command
|
22
|
+
|
23
|
+
- Update the gemfile. Switch over to using the webpacker gem.
|
18
24
|
|
19
25
|
```rb
|
20
|
-
gem "webpacker"
|
21
|
-
branch: "issue-464-merge-webpacker-lite-into-webpacker-v5"
|
26
|
+
gem "webpacker"
|
22
27
|
```
|
23
28
|
|
24
29
|
- Update for the renaming in the `WebpackConfigLoader` in your webpack configuration.
|
@@ -80,22 +85,26 @@ gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
|
|
80
85
|
- Rename `webpack_public_output_dir` to `public_output_path`.
|
81
86
|
|
82
87
|
- Edit your Procfile.dev
|
83
|
-
-
|
84
|
-
|
85
|
-
- Edit your static procfile to set env value WEBPACKER_DEV_SERVER=FALSE
|
86
|
-
- For hot loading, either:
|
88
|
+
- Remove the env value WEBPACKER_DEV_SERVER as it's not used
|
89
|
+
- For hot loading:
|
87
90
|
- Set the `hmr` key in your `webpacker.yml` to `true`.
|
88
|
-
- Edit your hot procfile to set env value WEBPACKER_HMR=TRUE
|
89
91
|
|
90
92
|
|
91
93
|
#### Troubleshooting
|
92
|
-
* Be sure to
|
93
94
|
|
94
95
|
|
95
96
|
|
96
97
|
### [9.0.0]
|
97
98
|
*Diffs for the beta to master*
|
98
99
|
|
100
|
+
### [9.0.0-beta.12]
|
101
|
+
- Updated for latest rails/webpacker using the official gem
|
102
|
+
- hot reloading working in generator
|
103
|
+
|
104
|
+
### [9.0.0-beta.11]
|
105
|
+
- Updated for latest rails_webpacker.
|
106
|
+
- hot reloading working in spec/dummy
|
107
|
+
|
99
108
|
### [9.0.0-beta.10]
|
100
109
|
- Updated for the latest rails/webpacker. Added the cache_manifest setting.
|
101
110
|
|
@@ -131,6 +140,10 @@ gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
|
|
131
140
|
### [9.0.0-beta.1]
|
132
141
|
- First version of depending on Webpacker rather than Webpacker Lite
|
133
142
|
|
143
|
+
### [8.0.7]
|
144
|
+
#### fixed
|
145
|
+
- Fixes generator bug by keeping blank line at top in case existing .gitignore does not end in a newline. [#916](https://github.com/shakacode/react_on_rails/pull/916) by [justin808](https://github.com/justin808).
|
146
|
+
|
134
147
|
### [8.0.6]
|
135
148
|
#### fixed
|
136
149
|
- Fixes server rendering when using a CDN. Server rendering would try to fetch a file with the "asset_host". This change updates the webpacker_lite dependency to 2.1.0 which has a new helper `pack_path`. [#901](https://github.com/shakacode/react_on_rails/pull/901) by [justin808](https://github.com/justin808). Be sure to update webpacker_lite to 2.1.0.
|
@@ -751,6 +764,7 @@ Best done with Object destructing:
|
|
751
764
|
|
752
765
|
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/rails-webpacker...9.0.0-beta.11
|
753
766
|
[9.0.0]: https://github.com/shakacode/react_on_rails/compare/master...9.0.0-beta.11
|
767
|
+
[9.0.0-beta.12]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.11...9.0.0-beta.12
|
754
768
|
[9.0.0-beta.11]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.10...9.0.0-beta.11
|
755
769
|
[9.0.0-beta.10]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.9...9.0.0-beta.10
|
756
770
|
[9.0.0-beta.9]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.8...9.0.0-beta.9
|
@@ -762,6 +776,7 @@ Best done with Object destructing:
|
|
762
776
|
[9.0.0-beta.3]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.2...9.0.0-beta.3
|
763
777
|
[9.0.0-beta.2]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.1...9.0.0-beta.2
|
764
778
|
[9.0.0-beta.1]: https://github.com/shakacode/react_on_rails/compare/master...9.0.0-beta.1
|
779
|
+
[8.0.7]: https://github.com/shakacode/react_on_rails/compare/8.0.6...8.0.7
|
765
780
|
[8.0.6]: https://github.com/shakacode/react_on_rails/compare/8.0.5...8.0.6
|
766
781
|
[8.0.5]: https://github.com/shakacode/react_on_rails/compare/8.0.3...8.0.5
|
767
782
|
[8.0.3]: https://github.com/shakacode/react_on_rails/compare/8.0.2...8.0.3
|
data/Gemfile
CHANGED
@@ -38,10 +38,10 @@ gem "chromedriver-helper"
|
|
38
38
|
gem "launchy"
|
39
39
|
gem "poltergeist"
|
40
40
|
gem "selenium-webdriver"
|
41
|
-
gem "webpacker",
|
42
|
-
branch: "issue-464-merge-webpacker-lite-into-webpacker-v5"
|
41
|
+
gem "webpacker", "~> 3.0"
|
43
42
|
|
44
43
|
# TODO: remove once we get out of beta.
|
45
44
|
# gem 'webpacker', path: "../../forks/webpacker"
|
46
45
|
|
46
|
+
gem "equivalent-xml", github: "mbklein/equivalent-xml"
|
47
47
|
gem "rainbow"
|
data/Gemfile.rails32
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
eval_gemfile File.expand_path("../react_on_rails.gemspec", __FILE__)
|
6
|
+
|
7
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
8
|
+
gem "rails", "~> 3.2"
|
9
|
+
# Use sqlite3 as the database for Active Record
|
10
|
+
gem "sqlite3"
|
11
|
+
# Use SCSS for stylesheets
|
12
|
+
gem "sass-rails"
|
13
|
+
# Use Uglifier as compressor for JavaScript assets
|
14
|
+
gem "uglifier"
|
15
|
+
# Use CoffeeScript for .coffee assets and views
|
16
|
+
gem "coffee-rails"
|
17
|
+
|
18
|
+
# Use jquery as the JavaScript library
|
19
|
+
gem "jquery-rails"
|
20
|
+
|
21
|
+
gem "puma"
|
22
|
+
|
23
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
24
|
+
gem "jbuilder"
|
25
|
+
# bundle exec rake doc:rails generates the API under doc/api.
|
26
|
+
gem "sdoc", group: :doc
|
27
|
+
|
28
|
+
# Use ActiveModel has_secure_password
|
29
|
+
# gem 'bcrypt', '~> 3.1.7'
|
30
|
+
|
31
|
+
# Use Unicorn as the app server
|
32
|
+
# gem 'unicorn'
|
33
|
+
|
34
|
+
# Use Capistrano for deployment
|
35
|
+
# gem 'capistrano-rails', group: :development
|
36
|
+
|
37
|
+
gem "mini_racer"
|
38
|
+
gem "connection_pool"
|
39
|
+
gem "rainbow"
|
40
|
+
gem "addressable"
|
41
|
+
gem "execjs"
|
42
|
+
|
43
|
+
group :development, :test do
|
44
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
45
|
+
gem "awesome_print"
|
46
|
+
gem "listen"
|
47
|
+
gem "pry"
|
48
|
+
gem "pry-byebug"
|
49
|
+
gem "pry-doc"
|
50
|
+
gem "pry-rails"
|
51
|
+
gem "pry-rescue"
|
52
|
+
gem "pry-stack_explorer"
|
53
|
+
gem "rubocop", require: false
|
54
|
+
gem "ruby-lint", require: false
|
55
|
+
gem "scss_lint", require: false
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
group :test do
|
60
|
+
gem "capybara"
|
61
|
+
gem "capybara-screenshot"
|
62
|
+
gem "coveralls", require: false
|
63
|
+
# install trouble with updated
|
64
|
+
# gem "capybara-webkit"
|
65
|
+
gem "chromedriver-helper"
|
66
|
+
gem "generator_spec"
|
67
|
+
gem "launchy"
|
68
|
+
gem "poltergeist"
|
69
|
+
gem "rspec-rails"
|
70
|
+
gem "rspec-retry"
|
71
|
+
gem "selenium-webdriver"
|
72
|
+
gem 'test-unit', '~> 3.0'
|
73
|
+
gem "equivalent-xml", github: "mbklein/equivalent-xml"
|
74
|
+
end
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
*If this projects helps you, please give us a star!*
|
4
4
|
|
5
|
+
[rails/webpacker](https://github.com/rails/webpacker) just shipped 3.0. This now enables me to ship version 9.0. See [PR #908](https://github.com/shakacode/react_on_rails/pull/908) for more details.
|
6
|
+
|
5
7
|
## Thank you from Justin Gordon and [ShakaCode](http://www.shakacode.com)
|
6
8
|
|
7
9
|
Thank you for considering using [React on Rails](https://github.com/shakacode/react_on_rails).
|
@@ -92,7 +94,7 @@ React on Rails integrates Facebook's [React](https://github.com/facebook/react)
|
|
92
94
|
+ [Features](#features)
|
93
95
|
+ [Why Webpack?](#why-webpack)
|
94
96
|
+ [Getting Started](#getting-started)
|
95
|
-
- [Installation
|
97
|
+
- [Installation Overview](#installation-overview)
|
96
98
|
- [Initializer Configuration: config/initializers/react_on_rails.rb](#initializer-configuration)
|
97
99
|
- [Including your React Component in your Rails Views](#including-your-react-component-in-your-rails-views)
|
98
100
|
- [I18n](#i18n)
|
@@ -105,7 +107,7 @@ React on Rails integrates Facebook's [React](https://github.com/facebook/react)
|
|
105
107
|
- [ReactOnRails JavaScript API](#reactonrails-javascript-api)
|
106
108
|
- [React-Router](#react-router)
|
107
109
|
- [Deployment](#deployment)
|
108
|
-
+ [Integration with Node](#integration-with-
|
110
|
+
+ [Integration with Node.js for Server Rendering](#user-content-integration-with-nodejs-for-server-rendering)
|
109
111
|
+ [Additional Documentation](#additional-documentation)
|
110
112
|
+ [Contributing](#contributing)
|
111
113
|
+ [License](#license)
|
@@ -144,9 +146,17 @@ To upgrade existing apps to React on Rails 8 see the [Installation Overview](doc
|
|
144
146
|
|
145
147
|
```ruby
|
146
148
|
gem "react_on_rails", "9.0.0"
|
149
|
+
gem "webpacker", "~> 3.0"
|
147
150
|
```
|
148
151
|
|
149
|
-
2.
|
152
|
+
2. Run the following 2 commands to install Webpacker with React:
|
153
|
+
```
|
154
|
+
bundle exec rails webpacker:install
|
155
|
+
bundle exec rails webpacker:install:react
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
2. Commit this to git (or else you cannot run the generator unless you pass the option `--ignore-warnings`).
|
150
160
|
|
151
161
|
3. See help for the generator:
|
152
162
|
|
@@ -160,13 +170,7 @@ To upgrade existing apps to React on Rails 8 see the [Installation Overview](doc
|
|
160
170
|
rails generate react_on_rails:install
|
161
171
|
```
|
162
172
|
|
163
|
-
5.
|
164
|
-
|
165
|
-
```bash
|
166
|
-
bundle && yarn
|
167
|
-
```
|
168
|
-
|
169
|
-
6. Ensure that you have `foreman` installed: `gem install foreman`.
|
173
|
+
5. Ensure that you have `foreman` installed: `gem install foreman`.
|
170
174
|
|
171
175
|
7. Start your Rails server:
|
172
176
|
|
@@ -405,12 +409,12 @@ end
|
|
405
409
|
In this case, a prop and value for `somethingUseful` will go into the railsContext passed to all react_component and redux_store calls. You may set any values available in the view rendering context.
|
406
410
|
|
407
411
|
### Globally Exposing Your React Components
|
408
|
-
Place your JavaScript code inside of the
|
412
|
+
Place your JavaScript code inside of the default `app/javascript` folder. Use modules just as you would when using webpack alone. The difference here is that instead of mounting React components directly to an element using `React.render`, you **register your components to ReactOnRails and then mount them with helpers inside of your Rails views**.
|
409
413
|
|
410
414
|
This is how to expose a component to the `react_component` view helper.
|
411
415
|
|
412
416
|
```javascript
|
413
|
-
//
|
417
|
+
// app/javascript/packs/hello-world-bundle.js
|
414
418
|
import HelloWorld from '../components/HelloWorld';
|
415
419
|
import ReactOnRails from 'react-on-rails';
|
416
420
|
ReactOnRails.register({ HelloWorld });
|
@@ -610,6 +614,7 @@ If you want to use a node server for server rendering, [get in touch](mailto:jus
|
|
610
614
|
+ **Development**
|
611
615
|
+ [React on Rails Basic Installation Tutorial](./docs/tutorial.md) ([live demo](https://hello-react-on-rails.herokuapp.com))
|
612
616
|
+ [Installation Overview](./docs/basics/installation-overview.md)
|
617
|
+
+ [Configuration](./docs/basics/configuration.md)
|
613
618
|
+ [Migration from react-rails](./docs/basics/migrating-from-react-rails.md)
|
614
619
|
+ [Recommended Project Structure](./docs/additional-reading/recommended-project-structure.md)
|
615
620
|
+ [Generator Tips](./docs/basics/generator.md)
|
data/Rakefile
CHANGED
@@ -3,12 +3,19 @@
|
|
3
3
|
# Rake will automatically load any *.rake files inside of the "rakelib" folder
|
4
4
|
# See rakelib/
|
5
5
|
tasks = %w[run_rspec lint]
|
6
|
+
prepare_for_ci = %w[node_package dummy_apps examples]
|
7
|
+
|
6
8
|
if ENV["USE_COVERALLS"] == "TRUE"
|
7
9
|
require "coveralls/rake/task"
|
8
10
|
Coveralls::RakeTask.new
|
9
11
|
tasks << "coveralls:push"
|
10
12
|
end
|
11
13
|
|
14
|
+
if File.basename(ENV["BUNDLE_GEMFILE"] || "") == "Gemfile.rails32"
|
15
|
+
tasks = %w[run_rspec:gem_rails32 run_rspec:dummy_no_webpacker]
|
16
|
+
prepare_for_ci = %w[node_package dummy_apps:dummy_no_webpacker]
|
17
|
+
end
|
18
|
+
|
12
19
|
desc "Run all tests and linting"
|
13
20
|
task default: tasks
|
14
21
|
|
@@ -16,7 +23,7 @@ desc "All actions but no examples, good for local developer run."
|
|
16
23
|
task all_but_examples: ["run_rspec:all_but_examples", "lint"]
|
17
24
|
|
18
25
|
desc "Prepare for ci, including node_package, dummy app, and generator examples"
|
19
|
-
task prepare_for_ci:
|
26
|
+
task prepare_for_ci: prepare_for_ci
|
20
27
|
|
21
28
|
desc "Runs prepare_for_ci and tasks"
|
22
29
|
task ci: [:prepare_for_ci, *tasks]
|
@@ -183,7 +183,7 @@ module ReactOnRailsHelper
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def sanitized_props_string(props)
|
186
|
-
props.is_a?(String) ?
|
186
|
+
ReactOnRails::JsonOutput.escape(props.is_a?(String) ? props : props.to_json)
|
187
187
|
end
|
188
188
|
|
189
189
|
# Helper method to take javascript expression and returns the output from evaluating it.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Asset Pipeline
|
2
|
+
|
3
|
+
The plumbing of webpack produced assets through the asset pipeline is deprecated as of v9.0.
|
4
|
+
|
5
|
+
The information in this document is here for those that have not yet upgraded.
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
This option still works for your `/config/initializers/react_on_rails.rb` if you are still using the
|
11
|
+
asset pipeline.
|
12
|
+
```
|
13
|
+
################################################################################
|
14
|
+
# MISCELLANEOUS OPTIONS
|
15
|
+
################################################################################
|
16
|
+
# If you want to use webpack for CSS and images, and still use the asset pipeline,
|
17
|
+
# see https://github.com/shakacode/react_on_rails/blob/master/docs/additional-reading/rails-assets.md
|
18
|
+
# And you will use a setting like this.
|
19
|
+
config.symlink_non_digested_assets_regex = /\.(png|jpg|jpeg|gif|tiff|woff|ttf|eot|svg|map)/
|
20
|
+
```
|
@@ -20,8 +20,6 @@ We'll use a Webpack Dev server on port 3500 to provide the assets to Rails, rath
|
|
20
20
|
|
21
21
|
`Procfile.static` provides an alternative that uses "static" assets, similar to a production deployment.
|
22
22
|
|
23
|
-
The secret sauce is in the [app/views/layouts/application.html.erb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/app/views/layouts/application.html.erb) where it uses view helps to configure the correct assets to load, being either the "hot" assets or the "static" assets.
|
24
|
-
|
25
23
|
## Places to Configure (Files to Examine)
|
26
24
|
|
27
25
|
1. See the Webpack config files. Note, these examples are now setup for using [CSS Modules](https://github.com/css-modules/css-modules).
|
@@ -44,76 +42,3 @@ The secret sauce is in the [app/views/layouts/application.html.erb](https://gith
|
|
44
42
|
## Code Snippets
|
45
43
|
Please refer to the examples linked above in `spec/dummy` as these code samples might be out of date.
|
46
44
|
|
47
|
-
|
48
|
-
### config/initializers/assets.rb
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
# Add folder with webpack generated assets to assets.paths
|
52
|
-
Rails.application.config.assets.paths << Rails.root.join("app", "assets", "webpack")
|
53
|
-
|
54
|
-
# Precompile additional assets.
|
55
|
-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
56
|
-
Rails.application.config.assets.precompile << "server-bundle.js"
|
57
|
-
|
58
|
-
type = ENV["REACT_ON_RAILS_ENV"] == "HOT" ? "non_webpack" : "static"
|
59
|
-
Rails.application.config.assets.precompile +=
|
60
|
-
[
|
61
|
-
"application_#{type}.js",
|
62
|
-
"application_#{type}.css"
|
63
|
-
]
|
64
|
-
```
|
65
|
-
|
66
|
-
### app/views/layouts/application.html.erb
|
67
|
-
|
68
|
-
```erb
|
69
|
-
<head>
|
70
|
-
<title>Dummy</title>
|
71
|
-
|
72
|
-
<!-- These do use turbolinks 5 -->
|
73
|
-
<%= env_stylesheet_link_tag(static: 'application_static',
|
74
|
-
hot: 'application_non_webpack',
|
75
|
-
media: 'all',
|
76
|
-
'data-turbolinks-track' => "reload") %>
|
77
|
-
|
78
|
-
<!-- These do not use turbolinks, so no data-turbolinks-track -->
|
79
|
-
<!-- This is to load the hot assets. -->
|
80
|
-
<%= env_javascript_include_tag(hot: ['http://localhost:3500/vendor-bundle.js',
|
81
|
-
'http://localhost:3500/app-bundle.js']) %>
|
82
|
-
|
83
|
-
<!-- These do use turbolinks 5 -->
|
84
|
-
<%= env_javascript_include_tag(static: 'application_static',
|
85
|
-
hot: 'application_non_webpack',
|
86
|
-
'data-turbolinks-track' => "reload") %>
|
87
|
-
|
88
|
-
<%= csrf_meta_tags %>
|
89
|
-
</head>
|
90
|
-
```
|
91
|
-
|
92
|
-
### Procfile.static
|
93
|
-
```
|
94
|
-
# Run Rails without hot reloading (static assets).
|
95
|
-
rails: REACT_ON_RAILS_ENV= rails s -b 0.0.0.0
|
96
|
-
|
97
|
-
# Build client assets, watching for changes.
|
98
|
-
rails-client-assets: yarn run build:dev:client
|
99
|
-
|
100
|
-
# Build server assets, watching for changes. Remove if not server rendering.
|
101
|
-
rails-server-assets: yarn run build:dev:server
|
102
|
-
```
|
103
|
-
|
104
|
-
### Procfile.hot
|
105
|
-
|
106
|
-
```
|
107
|
-
# Procfile for development with hot reloading of JavaScript and CSS
|
108
|
-
|
109
|
-
# Development rails requires both rails and rails-assets
|
110
|
-
# (and rails-server-assets if server rendering)
|
111
|
-
rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0
|
112
|
-
|
113
|
-
# Run the hot reload server for client development
|
114
|
-
hot-assets: HOT_RAILS_PORT=3500 yarn run hot-assets
|
115
|
-
|
116
|
-
# Keep the JS fresh for server rendering. Remove if not server rendering
|
117
|
-
rails-server-assets: yarn run build:dev:server
|
118
|
-
```
|
119
|
-
|