react_on_rails 1.1.1 → 1.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -0
  4. data/.travis.yml +2 -8
  5. data/Dockerfile_tests +1 -1
  6. data/Gemfile +68 -2
  7. data/README.md +21 -15
  8. data/Rakefile +3 -109
  9. data/app/assets/javascripts/react_on_rails.js +10 -0
  10. data/docker-compose.yml +0 -6
  11. data/docs/additional_reading/webpack.md +46 -0
  12. data/docs/generator_testing.md +20 -0
  13. data/lib/generators/react_on_rails/base_generator.rb +49 -9
  14. data/lib/generators/react_on_rails/bootstrap_generator.rb +14 -29
  15. data/lib/generators/react_on_rails/dev_tests_generator.rb +30 -0
  16. data/lib/generators/react_on_rails/install_generator.rb +14 -3
  17. data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +2 -3
  18. data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +26 -23
  19. data/lib/generators/react_on_rails/templates/base/base/client/{webpack.client.hot.config.js → webpack.client.hot.config.js.tt} +3 -1
  20. data/lib/generators/react_on_rails/templates/base/base/lib/tasks/{assets.rake → assets.rake.tt} +2 -0
  21. data/lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js +1 -1
  22. data/lib/generators/react_on_rails/templates/dev_tests/.rspec +2 -0
  23. data/lib/generators/react_on_rails/templates/dev_tests/spec/features/hello_world_spec.rb +25 -0
  24. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +57 -0
  25. data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +21 -0
  26. data/lib/generators/react_on_rails/templates/dev_tests/spec/spec_helper.rb +95 -0
  27. data/lib/react_on_rails/version.rb +1 -1
  28. data/rakelib/docker.rake +33 -0
  29. data/rakelib/dummy_apps.rake +29 -0
  30. data/rakelib/example_type.rb +160 -0
  31. data/rakelib/examples.rake +103 -0
  32. data/rakelib/examples_config.yml +19 -0
  33. data/rakelib/lint.rake +37 -0
  34. data/rakelib/run_rspec.rake +65 -0
  35. data/rakelib/task_helpers.rb +44 -0
  36. data/ruby-lint.yml +1 -0
  37. metadata +22 -9
  38. data/Dockerfile_ci +0 -12
  39. data/docs/generator_testing_script.md +0 -49
  40. data/lib/generators/react_on_rails/templates/client/README.md +0 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ec601fd7a8ddbadbe47c0293045aa5cfb372172
4
- data.tar.gz: 8416f87f0edaca37fe579318312b8e55da00a070
3
+ metadata.gz: 0cb4379ac90c02126dfcab3c5be352db3e02d2c0
4
+ data.tar.gz: f0f2baf8c27160f8dcc7ad6d877935734ebff3c9
5
5
  SHA512:
6
- metadata.gz: 68af87cb975272a0607689d5207f7cf53d49c04b141adac278f7aaa6038e6c86c4c5d2c962dc6733cc5a6fa1b70cb9f1f8cd424262f7c70a4a6f43eb7f3ffe4f
7
- data.tar.gz: 052141635f38970e32898fba7bb3aa87fa2f6ea5918f18f1cd9ce577d616ce1098717beac514363b8d09b09423386df1f8fda9b78ae5b6296624d6f07a0b67b1
6
+ metadata.gz: 02f567c3a9f6b4712d8d9ca2671596ca63cadaf427b7272445aa2aa2aaebcb2558d267f4f3e1c3da3a84208a57d016a2666d9d0bfba21cc2e33d3cb84b1f4aec
7
+ data.tar.gz: f0ff60e1e71582b805071affe7c91d8139f50ef0976587d446f8fd1dd08ea370d497ebb766380e3cc6723d01d677d11f4a5685a500a7a4f164aeb88c865fa454
data/.gitignore CHANGED
@@ -23,3 +23,4 @@
23
23
  .ruby-gemset
24
24
 
25
25
  node_modules
26
+ examples
data/.rubocop.yml CHANGED
@@ -17,6 +17,7 @@ AllCops:
17
17
  - 'bin/**/*'
18
18
  - !ruby/regexp /old_and_unused\.rb$/
19
19
  - 'spec/react_on_rails/dummy-for-generators/**/*'
20
+ - 'examples/**/*'
20
21
 
21
22
  Metrics/LineLength:
22
23
  Max: 120
data/.travis.yml CHANGED
@@ -25,13 +25,8 @@ install:
25
25
  - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install 4.2.0
26
26
  - npm install -g npm
27
27
  - bundle install
28
- - cd spec/dummy/client && npm install
29
- - $(npm bin)/webpack --config webpack.server.js
30
- - $(npm bin)/webpack --config webpack.client.js
31
- - cd ../../dummy-react-013/client && npm install
32
- - $(npm bin)/webpack --config webpack.server.js
33
- - $(npm bin)/webpack --config webpack.client.js
34
- - cd ../../../
28
+ - rake dummy_apps
29
+ - rake examples
35
30
  - docker-compose up lint
36
31
 
37
32
  before_script:
@@ -40,7 +35,6 @@ before_script:
40
35
 
41
36
  script:
42
37
  - rake
43
- - rake docker:lint
44
38
 
45
39
  notifications:
46
40
  slack:
data/Dockerfile_tests CHANGED
@@ -3,7 +3,7 @@ FROM dylangrafmyre/docker-ci
3
3
  WORKDIR /app/
4
4
 
5
5
  COPY ["/lib/react_on_rails/version.rb", "/app/lib/react_on_rails/"]
6
- COPY ["Gemfile", "Gemfile.lock", "react_on_rails.gemspec", "/app/"]
6
+ COPY ["Gemfile", "Gemfile.lock", "react_on_rails.gemspec", "rakelib/", "/app/"]
7
7
  COPY ["/spec/dummy/Gemfile", "/spec/dummy/Gemfile.lock", "/app/spec/dummy/"]
8
8
  RUN bundle install --gemfile=spec/dummy/Gemfile
9
9
 
data/Gemfile CHANGED
@@ -1,4 +1,70 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in react_on_rails.gemspec
3
+ # Specify your gem"s dependencies in react_on_rails.gemspec
4
4
  gemspec
5
+
6
+ # Bundle edge Rails instead: gem "rails", github: "rails/rails"
7
+ gem "rails", "4.2.5"
8
+ # Use sqlite3 as the database for Active Record
9
+ gem "sqlite3"
10
+ # Use SCSS for stylesheets
11
+ gem "sass-rails", "~> 5.0"
12
+ # Use Uglifier as compressor for JavaScript assets
13
+ gem "uglifier", ">= 2.7.2"
14
+ # Use CoffeeScript for .coffee assets and views
15
+ gem "coffee-rails", "~> 4.1.0"
16
+ # See https://github.com/rails/execjs#readme for more supported runtimes
17
+ # gem "therubyracer", platforms: :ruby
18
+
19
+ # Use jquery as the JavaScript library
20
+ gem "jquery-rails"
21
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
22
+ gem "turbolinks"
23
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
24
+ gem "jbuilder", "~> 2.0"
25
+ # bundle exec rake doc:rails generates the API under doc/api.
26
+ gem "sdoc", "~> 0.4.0", 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 "therubyracer"
38
+
39
+ group :development, :test do
40
+ # Call "byebug" anywhere in the code to stop execution and get a debugger console
41
+ gem "pry"
42
+ gem "pry-doc"
43
+ gem "pry-rails"
44
+ gem "pry-stack_explorer"
45
+ gem "pry-rescue"
46
+ gem "pry-byebug"
47
+ gem "awesome_print"
48
+ gem "rubocop", require: false
49
+ gem "ruby-lint", require: false
50
+ gem "scss_lint", require: false
51
+
52
+ # Access an IRB console on exception pages or by using <%= console %> in views
53
+ gem "web-console", "~> 2.0"
54
+
55
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
56
+ gem "spring"
57
+ end
58
+
59
+ gem "bootstrap-sass"
60
+
61
+ group :test do
62
+ gem "rspec-rails"
63
+ gem "coveralls", require: false
64
+ gem "capybara"
65
+ gem "capybara-screenshot"
66
+ gem "selenium-webdriver"
67
+ gem "chromedriver-helper"
68
+ gem "launchy"
69
+ gem "generator_spec"
70
+ end
data/README.md CHANGED
@@ -51,6 +51,7 @@ Please see [Getting Started](#getting-started) for how to set up your Rails proj
51
51
  + [Bootstrap via Rails Server](#bootstrap-via-rails-server)
52
52
  + [Bootstrap via Webpack HMR Dev Server](#bootstrap-via-webpack-hmr-dev-server)
53
53
  + [Keeping Custom Bootstrap Configurations Synced](#keeping-custom-bootstrap-configurations-synced)
54
+ + [Skip Bootstrap Integration](#skip-bootstrap-integration)
54
55
  - [Linters](#linters)
55
56
  + [JavaScript Linters](#javascript-linters)
56
57
  + [Ruby Linters](#ruby-linters)
@@ -75,7 +76,7 @@ Like the [react-rails](https://github.com/reactjs/react-rails) gem, React on Rai
75
76
  + *([Gem *Pull Request*](https://github.com/shakacode/react_on_rails/pull/68))*
76
77
  + *([Tutorial Pull Request](https://github.com/shakacode/react-webpack-rails-tutorial/pull/128))*
77
78
 
78
- See the [react-webpack-rails-tutorial](https://github.com/justin808/react-webpack-rails-tutorial/) for an example of a live implementation and code.
79
+ See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
79
80
 
80
81
  ## Why Webpack?
81
82
 
@@ -84,7 +85,7 @@ Webpack is used for 2 purposes:
84
85
  1. Generate several JavaScript "bundles" for inclusion in `application.js`.
85
86
  2. Providing the Webpack Dev Server for quick prototyping of components without needing to refresh your browser to see updates.
86
87
 
87
- This usage of webpack fits neatly and simply into the existing Rails sprockets system and you can include React components on a Rails view with a simple helper.
88
+ This usage of webpack fits neatly and simply into the existing Rails sprockets system and you can include React components on a Rails view with a simple helper.
88
89
 
89
90
  Compare this to some alternative approaches for SPAs (Single Page Apps) that utilize Webpack and Rails. They will use a separate node server to distribute web pages, JavaScript assets, CSS, etc., and will still use Rails as an API server. A good example of this is our ShakaCode team member Alex's article [
90
91
  Universal React with Rails: Part I](https://medium.com/@alexfedoseev/isomorphic-react-with-rails-part-i-440754e82a59).
@@ -93,7 +94,7 @@ We're definitely not doing that. With react_on_rails, webpack is mainly generati
93
94
 
94
95
  ## Getting Started
95
96
  1. Add the following to your Gemfile and bundle install:
96
-
97
+
97
98
  ```ruby
98
99
  gem "react_on_rails"
99
100
  ```
@@ -128,7 +129,7 @@ In most cases, you should use the `prerender: false` (default behavior) with the
128
129
 
129
130
  Now the server will interpret your JavaScript using [ExecJS](https://github.com/rails/execjs) and pass the resulting HTML to the client. We recommend using [therubyracer](https://github.com/cowboyd/therubyracer) as ExecJS's runtime. The generator will automatically add it to your Gemfile for you.
130
131
 
131
- Note that **server-rendering requires globally exposing your components by setting them to `global`, not `window`** (as is the case with client-rendering). If using the generator, you can pass the `--server-rendering` option to configure your application for server-side rendering.
132
+ Note that **server-rendering requires globally exposing your components by setting them to `global`, not `window`** (as is the case with client-rendering). If using the generator, you can pass the `--server-rendering` option to configure your application for server-side rendering.
132
133
 
133
134
  In the following screenshot you can see the 3 parts of react_on_rails rendering:
134
135
 
@@ -149,28 +150,28 @@ On Heroku deploys, the `lib/assets.rake` file takes care of running webpack duri
149
150
  Place your JavaScript code inside of the provided `client/app` 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 **expose your components globally and then mount them with helpers inside of your Rails views**.
150
151
 
151
152
  + *Normal Mode (JavaScript is Rendered on client):*
152
-
153
+
153
154
  If you are not server rendering, `clientGlobals.jsx` will have
154
-
155
+
155
156
  ```javascript
156
157
  window.HelloWorldApp = HelloWorldApp;
157
158
  ```
158
159
  + *Server-Side Rendering:*
159
160
 
160
161
  If you are server rendering, `globals.jsx` will have:
161
-
162
+
162
163
  ```javascript
163
164
  window.HelloWorldApp = HelloWorldAppClient;
164
165
  ```
165
-
166
+
166
167
  `serverGlobals.jsx` will have:
167
-
168
+
168
169
  ```javascript
169
170
  global.HelloWorldApp = HelloWorldAppServer;
170
171
  ```
171
-
172
+
172
173
  In general, you want different initialization for your server rendered components.
173
-
174
+
174
175
  ### Rails View Helpers In-Depth
175
176
  Once the bundled files have been generated in your `app/assets/javascripts/generated` folder and you have exposed your components globally, you will want to run your code in your Rails views using the included helper method.
176
177
 
@@ -213,6 +214,7 @@ Options:
213
214
  -j, [--skip-js-linters], [--no-skip-js-linters] # Skip installing JavaScript linting files
214
215
  -L, [--ruby-linters], [--no-ruby-linters] # Install ruby linting files, tasks, and configs
215
216
  -H, [--heroku-deployment], [--no-heroku-deployment] # Install files necessary for deploying to Heroku
217
+ -b, [--skip-bootstrap], [--no-skip-bootstrap] # Skip installing files for bootstrap support
216
218
 
217
219
  Runtime options:
218
220
  -f, [--force] # Overwrite files that already exist
@@ -224,7 +226,7 @@ Description:
224
226
  Create react on rails files for install generator.
225
227
  ```
226
228
 
227
- For a clear example of what each generator option will do, see our generator results repo: [Generator Results](https://github.com/shakacode/react_on_rails-generator-results-1-0-0/pulls). Each pull request shows a git "diff" that highlights the changes that the generator has made.
229
+ For a clear example of what each generator option will do, see our generator results repo: [Generator Results](https://github.com/shakacode/react_on_rails-generator-results/pulls). Each pull request shows a git "diff" that highlights the changes that the generator has made.
228
230
 
229
231
  ### Understanding the Organization of the Generated Client Code
230
232
  The generated client code follows our organization scheme. Each unique set of functionality, is given its own folder inside of `client/app/bundles`. This encourages for modularity of DOMAINS.
@@ -238,7 +240,7 @@ Inside of the generated "HelloWorld" domain you will find the following folders:
238
240
  You may also notice the `app/lib` folder. This is for any code that is common between bundles and therefore needs to be shared (for example, middleware).
239
241
 
240
242
  ### Redux
241
- 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.
243
+ 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.
242
244
 
243
245
  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`.
244
246
 
@@ -263,6 +265,9 @@ When using the webpack dev server, which does not go through Rails, bootstrap is
263
265
  #### Keeping Custom Bootstrap Configurations Synced
264
266
  Because the webpack dev server and Rails each load Bootstrap via a different file (explained in the two sections immediately above), any changes to the way components are loaded in one file must also be made to the other file in order to keep styling consistent between the two. For example, if an import is excluded in `_bootstrap-custom.scss`, the same import should be excluded in `bootstrap-sass-config.js` so that styling in the Rails server and the webpack dev server will be the same.
265
267
 
268
+ #### Skip Bootstrap Integration
269
+ Bootstrap integration is enabled by default, but can be disabled by passing the `--skip-bootstrap` flag (alias `-b`). When you don't need Bootstrap in your existing project, just skip it as needed.
270
+
266
271
  ### Linters
267
272
  The React on Rails generator can add linters and their recommended accompanying configurations to your project. There are two classes of linters: ruby linters and JavaScript linters.
268
273
 
@@ -319,10 +324,11 @@ As you add more routes to your front-end application, you will need to make the
319
324
  + [Heroku Deployment](docs/additional_reading/heroku_deployment.md)
320
325
  + [Manual Installation](docs/additional_reading/manual_installation.md)
321
326
  + [Node Dependencies and NPM](docs/additional_reading/node_dependencies_and_npm.md)
322
- + [Optional Configuration](docs/additional_reading/optional_configuration.md)
327
+ + [Optional Configuration](docs/additional_reading/optional_configuration.md)
323
328
  + [React Router](docs/additional_reading/react_router.md)
324
329
  + [Server Rendering Tips](docs/additional_reading/server_rendering_tips.md)
325
330
  + [Tips](docs/additional_reading/tips.md)
331
+ + [Webpack Configuration](docs/additional_reading/webpack.md)
326
332
 
327
333
  ## Contributing
328
334
  Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to our version of the [Contributor Covenant](contributor-covenant.org) code of conduct (see [CODE OF CONDUCT](docs/code_of_conduct.md)).
@@ -347,7 +353,7 @@ And based on the work of the [react-rails gem](https://github.com/reactjs/react-
347
353
 
348
354
  ## About [ShakaCode](http://www.shakacode.com/)
349
355
 
350
- Visit [our forums!](http://forum.shakacode.com). We've got a [category dedicated to react_on_rails](http://forum.shakacode.com/c/rails/reactonrails).
356
+ Visit [our forums!](http://forum.shakacode.com). We've got a [category dedicated to react_on_rails](http://forum.shakacode.com/c/rails/reactonrails).
351
357
 
352
358
  If you're looking for consulting on a project using React and Rails, email us ([contact@shakacode.com](mailto: contact@shakacode.com))! You can also join our slack room for some free advice.
353
359
 
data/Rakefile CHANGED
@@ -1,111 +1,5 @@
1
- require "fileutils"
2
- require "coveralls/rake/task"
3
-
4
- namespace :run_rspec do
5
- desc "Run RSpec for top level only"
6
- task :gem do
7
- sh %( COVERAGE=true rspec spec/react_on_rails )
8
- end
9
-
10
- desc "Run RSpec for spec/dummy only"
11
- task :dummy do
12
- # TEST_ENV_NUMBER is used to make SimpleCov.command_name unique in order to
13
- # prevent a name collision
14
- sh %( cd spec/dummy && DRIVER=selenium_firefox COVERAGE=true TEST_ENV_COMMAND_NAME="dummy-tests" rspec )
15
- end
16
-
17
- desc "Run RSpec for spec/dummy only"
18
- task :dummy_react_013 do
19
- # TEST_ENV_NUMBER is used to make SimpleCov.command_name unique in order to
20
- # prevent a name collision
21
- sh %( cd spec/dummy-react-013 &&
22
- DRIVER=selenium_firefox COVERAGE=true TEST_ENV_COMMAND_NAME="dummy-react-013-tests" rspec )
23
- end
24
-
25
- desc "Run RSpec on spec/empty_spec in order to have SimpleCov generate a coverage report from cache"
26
- task :empty do
27
- sh %( COVERAGE=true rspec spec/empty_spec.rb )
28
- end
29
-
30
- Coveralls::RakeTask.new
31
-
32
- task run_rspec: [:gem, :dummy, :dummy_react_013, :empty, "coveralls:push"] do
33
- puts "Completed all RSpec tests"
34
- end
35
- end
36
- desc "Runs all tests. Run `rake -D run_rspec` to see all available test options"
37
- task run_rspec: ["run_rspec:run_rspec"]
38
-
39
- task default: ["run_rspec", "docker:lint"]
40
-
41
- namespace :lint do
42
- desc "Run Rubocop as shell"
43
- task :rubocop do
44
- sh "rubocop ."
45
- end
46
-
47
- desc "Run ruby-lint as shell"
48
- task :ruby do
49
- sh "ruby-lint app spec lib"
50
- end
51
-
52
- desc "Run scss-lint as shell"
53
- task :scss do
54
- sh "scss-lint spec/dummy/app/assets/stylesheets/"
55
- end
56
-
57
- desc "Run eslint as shell"
58
- task :eslint do
59
- sh "eslint . --ext .jsx and .js"
60
- end
61
-
62
- desc "Run jscs from shell"
63
- task :jscs do
64
- sh "jscs -e -v ."
65
- end
66
-
67
- desc "Run all eslint, jscs, rubocop linters. Skip ruby-lint and scss"
68
- task lint: [:eslint, :jscs, :rubocop] do
69
- puts "Completed all linting"
70
- end
71
- end
72
-
73
- desc "Runs all linters. Run `rake -D lint` to see all available lint options"
74
- task lint: ["lint:lint"]
75
-
76
- namespace :docker do
77
- desc "Run Rubocop linter from docker"
78
- task :rubocop do
79
- sh "docker-compose run lint rake lint:rubocop"
80
- end
81
-
82
- desc "Run ruby-lint linter from docker"
83
- task :ruby do
84
- sh "docker-compose run lint rake lint:ruby"
85
- end
86
-
87
- desc "Run scss-lint linter from docker"
88
- task :scss do
89
- sh "docker-compose run lint rake lint:scss"
90
- end
91
-
92
- desc "Run eslint linter from docker"
93
- task :eslint do
94
- sh "docker-compose run lint rake lint:eslint"
95
- end
96
-
97
- desc "Run jscs linter from docker"
98
- task :jscs do
99
- sh "docker-compose run lint rake lint:jscs"
100
- end
101
- desc "Run all linting from docker"
102
- task :lint do
103
- sh "docker-compose run lint rake lint"
104
- end
105
- end
106
-
107
- desc "Runs all linters from docker. Run `rake -D docker` to see all available lint options"
108
- task docker: ["docker:lint"]
1
+ # Rake will automatically load any *.rake files inside of the "rakelib" folder
2
+ # See rakelib/
109
3
 
110
4
  desc "Run all tests and linting"
111
- task ci: %w(run_rspec lint)
5
+ task default: ["run_rspec", "docker:lint"]
@@ -200,6 +200,11 @@
200
200
 
201
201
  function provideClientReact() {
202
202
  if (typeof ReactDOM === 'undefined') {
203
+ if (React.version >= '0.14') {
204
+ console.warn('WARNING: ReactDOM is not configured in webpack.server.rails.config.js file as an entry.\n' +
205
+ 'See: https://github.com/shakacode/react_on_rails/blob/master/docs/webpack.md for more detailed hints.');
206
+ }
207
+
203
208
  return React;
204
209
  }
205
210
 
@@ -208,6 +213,11 @@
208
213
 
209
214
  function provideServerReact() {
210
215
  if (typeof ReactDOMServer === 'undefined') {
216
+ if (React.version >= '0.14') {
217
+ console.warn('WARNING: `react-dom/server` is not configured in webpack.server.rails.config.js file as an entry.\n' +
218
+ 'See: https://github.com/shakacode/react_on_rails/blob/master/docs/webpack.md for more detailed hints.');
219
+ }
220
+
211
221
  return React;
212
222
  }
213
223
 
data/docker-compose.yml CHANGED
@@ -1,9 +1,3 @@
1
- ci:
2
- build: .
3
- dockerfile: Dockerfile_ci
4
- working_dir: /app/
5
- volumes:
6
- - '.:/app/'
7
1
  lint:
8
2
  image: dylangrafmyre/docker-lint
9
3
  working_dir: /app/
@@ -0,0 +1,46 @@
1
+ # Entry Points and Globally Exposing Objects
2
+
3
+ You should ensure you configure the entry points correctly for webpack.
4
+
5
+ ## When using React 0.14 and greater
6
+
7
+ You need both include `react-dom/server` and `react` as values for `entry`, like this:
8
+
9
+ ```
10
+ entry: {
11
+
12
+ // See use of 'vendor' in the CommonsChunkPlugin inclusion below.
13
+ vendor: [
14
+ 'babel-core/polyfill',
15
+ 'jquery',
16
+ 'jquery-ujs',
17
+ 'react',
18
+ 'react-dom',
19
+ ],
20
+ ```
21
+
22
+ and you need to expose them:
23
+
24
+ ```
25
+ // React is necessary for the client rendering:
26
+ {test: require.resolve('react'), loader: 'expose?React'},
27
+ {test: require.resolve('react-dom'), loader: 'expose?ReactDOM'},
28
+ {test: require.resolve('jquery'), loader: 'expose?jQuery'},
29
+ {test: require.resolve('jquery'), loader: 'expose?$'},
30
+ ```
31
+
32
+ `webpack.server.config.js` is similar, but substitute:
33
+
34
+ ```
35
+ entry: ['./yourCode', 'react-dom/server', 'react'],
36
+ ```
37
+
38
+ and use this line rather than `{test: require.resolve('react-dom'), loader: 'expose?ReactDOM'},`:
39
+
40
+ ```
41
+ {test: require.resolve('react-dom/server'), loader: 'expose?ReactDOMServer'},
42
+ ```
43
+
44
+ ## When you use React 0.13
45
+
46
+ You don't need to put in react-dom.