react_on_rails 4.0.0.beta.1 → 4.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintignore +1 -0
  3. data/.gitignore +2 -1
  4. data/.jscsrc +1 -0
  5. data/.rubocop.yml +3 -0
  6. data/.travis.yml +1 -1
  7. data/CHANGELOG.md +12 -4
  8. data/Gemfile +0 -5
  9. data/README.md +10 -3
  10. data/Rakefile +3 -0
  11. data/app/helpers/react_on_rails_helper.rb +21 -18
  12. data/docs/additional_reading/manual_installation.md +2 -2
  13. data/docs/additional_reading/optional_configuration.md +1 -1
  14. data/docs/additional_reading/rspec_configuration.md +3 -1
  15. data/docs/additional_reading/turbolinks.md +4 -3
  16. data/docs/contributing.md +1 -1
  17. data/docs/tutorial-v2.md +1 -1
  18. data/lib/generators/react_on_rails/base_generator.rb +20 -16
  19. data/lib/generators/react_on_rails/bootstrap_generator.rb +1 -1
  20. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-hot.tt +1 -1
  21. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +1 -1
  22. data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js +1 -1
  23. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +11 -1
  24. data/lib/generators/react_on_rails/templates/base/base/lib/tasks/assets.rake.tt +1 -1
  25. data/lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js +1 -1
  26. data/lib/react_on_rails/configuration.rb +51 -11
  27. data/lib/react_on_rails/controller.rb +2 -2
  28. data/lib/react_on_rails/server_rendering_pool.rb +2 -2
  29. data/lib/react_on_rails/test_helper.rb +31 -25
  30. data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +84 -34
  31. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +20 -12
  32. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +35 -32
  33. data/lib/react_on_rails/test_helper/webpack_process_checker.rb +17 -13
  34. data/lib/react_on_rails/utils.rb +5 -0
  35. data/lib/react_on_rails/version.rb +1 -1
  36. data/package.json +1 -2
  37. data/rakelib/node_package.rake +1 -8
  38. data/rakelib/run_rspec.rake +29 -10
  39. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbaf8ec483e9950e41d61c2e22b62b325113b00a
4
- data.tar.gz: 6e2da43df3e19adaffa7ff8a386fd39faa55c4b9
3
+ metadata.gz: 7201a4cf1cd742f3daa732436004d85ca67b8703
4
+ data.tar.gz: 02719ebb4f5feb84506f83b10417e864ca5ca6ff
5
5
  SHA512:
6
- metadata.gz: 9f716fc038e89ab1f26049d01bc9cfce53717cd40f0705c94a92906aee8f1f340b1b9e1eeb6adddfcf9bb4cc889de3b2638645b7fb78990b543fda4933c80b3c
7
- data.tar.gz: 6befd861e58a261de37c42eb332156bd67b125dbbe0823e6d2a42a59b02c0cd8fe4ed5ea49ded2e97d438829d48a206ffe73bd4d03048d6fc595d19fd2d5649d
6
+ metadata.gz: 41cfaad0da66d9771852126d6f64cb3615d080a827ec8a5a3be328f0f69f4d7a135d15b26a0cf5e4d79900a8634bcfbd6dae9b1ffc1d103e9633ffd4d57e8981
7
+ data.tar.gz: 8ecb0b33b5b958408917eee8ca024756448c00553b0d863163ee4ffbf371f66c22cf282fbee526d925810e07dac42db7a46ee06798c3dc6a153bbefa53f39a69
@@ -6,6 +6,7 @@ node_package/lib/
6
6
  node_package/tests/node_modules
7
7
  node_package/webpack.config.js
8
8
  **/node_modules/**
9
+ **/assets/webpack/**
9
10
  **/generated/**
10
11
  **/app/assets/javascripts/application.js
11
12
  **/coverage/**
data/.gitignore CHANGED
@@ -10,8 +10,9 @@
10
10
  *.gem
11
11
  /vendor/
12
12
 
13
+ /spec/examples.txt
13
14
  /spec/dummy/client/node_modules
14
- /spec/dummy/app/assets/javascripts/generated/
15
+ /spec/dummy/app/assets/webpack/
15
16
  /spec/dummy/coverage/
16
17
  /spec/react_on_rails/dummy-for-generators/
17
18
 
data/.jscsrc CHANGED
@@ -7,6 +7,7 @@
7
7
  "excludeFiles": [
8
8
  "**/build/**",
9
9
  "**/node_modules/**",
10
+ "**/assets/webpack/**",
10
11
  "**/generated/**",
11
12
  "**/docs/**",
12
13
  "**/tmp/**",
@@ -2,9 +2,12 @@
2
2
  # Check out: https://github.com/bbatsov/rubocop
3
3
 
4
4
  AllCops:
5
+ TargetRubyVersion: 2.1
6
+
5
7
  Include:
6
8
  - '**/Rakefile'
7
9
  - '**/config.ru'
10
+
8
11
  Exclude:
9
12
  - 'vendor/**/*'
10
13
  - 'spec/fixtures/**/*'
@@ -12,7 +12,7 @@ gemfile:
12
12
  - spec/dummy/Gemfile
13
13
 
14
14
  env:
15
- - export RAILS_ENV=test DRIVER=selenium
15
+ - export RAILS_ENV=test DRIVER=selenium_chrome
16
16
 
17
17
  before_install:
18
18
  - sudo apt-get update
@@ -7,18 +7,26 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]
7
7
  ## [4.0.0.rc.1] - 2016-03-06
8
8
  ##### Added
9
9
  - Added controller `module ReactOnRails::Controller`. Adds method `redux_store` to setup redux stores in the view.
10
+ - Added option `defer: true` for view helper `redux_store`. This allows the view helper to specify the props for store hydration, yet still render the props at the bottom of the view.
10
11
  - Added view helper `redux_store_hydration_data` to render the props on the application's layout, near the bottom. This allows for the client hydration data to be parsed after the server rendering, which may result in a faster load time.
11
12
  - Added helpers `env_stylesheet_link_tag` and `env_javascript_include_tag` to support hot reloading Rails. See the [README.md](./README.md) for more details and see the example application in `spec/dummy`.
12
13
  - The checker for outdated bundles before running tests will default to including the directory with `server_bundle_js_file`.
13
-
14
+ - Better support for Turbolinks 5!
15
+ - Fixed generator check of uncommitted code for foreign languages. See [#303](https://github.com/shakacode/react_on_rails/pull/303) by [nmatyukov](https://github.com/nmatyukov).
16
+ - Added several parameters used for ensuring webpack assets are built for running tests:
17
+ - `config.generated_assets_dir`: Directory where your generated webpack assets go. You can have only **one** directory for this.
18
+ - `config.webpack_generated_files`: List of files that will get created in the `generated_assets_dir`. The test runner helper will ensure these generated files are newer than any of the files in the client directory.
19
+ ##### Changed
20
+ - Generator default for webpack generated assets is now `app/assets/webpack` as we use this for both JavaScript and CSS generated assets.
14
21
  ##### Fixed
15
- - The test runner assets up to date checker might see only the server rendering file, and assume that all assets are up to date.
22
+ - The test runner assets up to date checker is greatly improved.
16
23
  - Lots of doc updates!
17
24
  - Improved the **spec/dummy** sample app so that it supports CSS modules, hot reloading, etc, and it can server as a template for a new ReactOnRails installation.
18
25
 
19
26
  ##### Breaking Changes
20
- - Deprecated `redux_store` called from views. Call this method from your controller actions and place `redux_store_hydration_data` on your layout, near the bottom.
21
- - Removed the config default of the `config.server_bundle_js_file`. The default is blank, meaning no server rendering.
27
+ - Deprecated calling `redux_store(store_name, props)`. The API has changed. Use `redux_store(store_name, props: props, defer: false)` A new option called `defer` allows the rendering of store hydration at the bottom of the your layout. Place `redux_store_hydration_data` on your layout.
28
+ - `config.server_bundle_js_file` has changed. The default value is now blank, meaning no server rendering. Addtionally, if you specify the file name, you should not include the path, as that should be specified in the `config.generated_assets_dir`.
29
+ - `config.generated_assets_dirs` has been renamed to `config.generated_assets_dir` (singular) and it only takes one directory.
22
30
 
23
31
 
24
32
  ## [3.0.6] - 2016-03-01
data/Gemfile CHANGED
@@ -8,12 +8,9 @@ gemspec
8
8
  # bundle install from a single Gemfile. Therefore, all gems that we will need for any dummy/example
9
9
  # app have to be manually added to this file.
10
10
  gem "bootstrap-sass"
11
- gem "chromedriver-helper"
12
11
  gem "coffee-rails", "~> 4.1.0"
13
12
  gem "jbuilder", "~> 2.0"
14
13
  gem "jquery-rails"
15
- gem "launchy"
16
- gem "poltergeist"
17
14
  gem "puma"
18
15
  gem "rails", "4.2.5"
19
16
  gem "rails_12factor"
@@ -35,12 +32,10 @@ gem "web-console", "~> 2.0", group: :development
35
32
 
36
33
  # below are copied from spec/dummy/Gemfile
37
34
  gem "rspec-rails"
38
- gem "coveralls", require: false
39
35
  gem "capybara"
40
36
  gem "capybara-screenshot"
41
37
  gem "capybara-webkit"
42
38
  gem "chromedriver-helper"
43
- gem "generator_spec"
44
39
  gem "launchy"
45
40
  gem "poltergeist"
46
41
  gem "selenium-webdriver"
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Dependency Status](https://gemnasium.com/shakacode/react_on_rails.svg)](https://gemnasium.com/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)
2
2
 
3
3
  # NEWS
4
-
4
+ * 4.0.0 Highlights
5
+ * Better support for Turbolinks 5.
6
+ * Controller rendering of shared redux stores.
5
7
  * 2016-02-28: We added a [Projects page](PROJECTS.md). Please edit the page your project or [email us](mailto:contact@shakacode.com) and we'll add you. We also love stars as it helps us attract new users and contributors. [jbhatab](https://github.com/jbhatab) is leading an effort to ease the onboarding process for newbies with simpler project generators. See [#245](https://github.com/shakacode/react_on_rails/issues/245).
6
8
  * 3.0.6 shipped on Tuesday, 2016-03-01. Please see the [Changelog](CHANGELOG.md) for details, and let us know if you see any issues! [Migration steps from 1.x](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#migration-steps-v1-to-v2). [Migration steps from 2.x](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#migration-steps-v2-to-v3).
7
9
  * [RubyGems](https://rubygems.org/gems/react_on_rails/)
@@ -171,7 +173,7 @@ cd client && npm i --saveDev react-on-rails
171
173
  That will install the latest version and update your package.json.
172
174
 
173
175
  ## How it Works
174
- The generator installs your webpack files in the `client` folder. Foreman uses webpack to compile your code and output the bundled results to `app/assets/javascripts/generated`, which are then loaded by sprockets. These generated bundle files have been added to your `.gitignore` for your convenience.
176
+ The generator installs your webpack files in the `client` folder. Foreman uses webpack to compile your code and output the bundled results to `app/assets/webpack`, which are then loaded by sprockets. These generated bundle files have been added to your `.gitignore` for your convenience.
175
177
 
176
178
  Inside your Rails views, you can now use the `react_component` helper method provided by React on Rails. You can pass props directly to the react component helper. You can also initialize a Redux store with view helper `redux_store` so that the store can be shared amongst multiple React components. Your best bet is to scan the code inside of the [/spec/dummy](spec/dummy) sample app.
177
179
 
@@ -222,7 +224,7 @@ Place your JavaScript code inside of the provided `client/app` folder. Use modul
222
224
  In general, you may want different initialization for your server rendered components.
223
225
 
224
226
  ## ReactOnRails View Helpers API
225
- 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.
227
+ Once the bundled files have been generated in your `app/assets/webpack` folder and you have exposed your components globally, you will want to run your code in your Rails views using the included helper method.
226
228
 
227
229
  This is how you actually render the React components you exposed to `window` inside of `clientRegistration` (and `global` inside of `serverRegistration` if you are server rendering).
228
230
 
@@ -574,6 +576,11 @@ Note: If you have components from react-rails you want to use, then you will nee
574
576
  foreman start
575
577
  ```
576
578
 
579
+ ## Dependencies
580
+ + Ruby 2.1 or greater
581
+ + Rails 3.2 or greater
582
+ + Node 5.5 or great
583
+
577
584
  ## Contributing
578
585
  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 Code of Conduct](docs/code_of_conduct.md)).
579
586
 
data/Rakefile CHANGED
@@ -5,3 +5,6 @@ Coveralls::RakeTask.new
5
5
 
6
6
  desc "Run all tests and linting"
7
7
  task default: ["run_rspec", "lint", "coveralls:push"]
8
+
9
+ desc "All actions but no examples. Good for local developer run."
10
+ task all_but_examples: ["run_rspec:all_but_examples", "lint"]
@@ -19,7 +19,7 @@ module ReactOnRailsHelper
19
19
  # <%= env_stylesheet_link_tag(static: 'application_static',
20
20
  # hot: 'application_non_webpack',
21
21
  # media: 'all',
22
- # 'data-turbolinks-track' => true) %>
22
+ # 'data-turbolinks-track' => "reload") %>
23
23
  #
24
24
  # <!-- These do not use turbolinks, so no data-turbolinks-track -->
25
25
  # <!-- This is to load the hot assets. -->
@@ -29,7 +29,9 @@ module ReactOnRailsHelper
29
29
  # <!-- These do use turbolinks -->
30
30
  # <%= env_javascript_include_tag(static: 'application_static',
31
31
  # hot: 'application_non_webpack',
32
- # 'data-turbolinks-track' => true) %>
32
+ # 'data-turbolinks-track' => "reload") %>
33
+ #
34
+ # NOTE: for Turbolinks 2.x, use 'data-turbolinks-track' => true
33
35
  # See application.html.erb for usage example
34
36
  # https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/app%2Fviews%2Flayouts%2Fapplication.html.erb
35
37
  def env_javascript_include_tag(args = {})
@@ -104,7 +106,6 @@ module ReactOnRailsHelper
104
106
 
105
107
  # Setup the page_loaded_js, which is the same regardless of prerendering or not!
106
108
  # The reason is that React is smart about not doing extra work if the server rendering did its job.
107
- turbolinks_loaded = Object.const_defined?(:Turbolinks)
108
109
 
109
110
  props = {} if props.nil?
110
111
 
@@ -112,7 +113,6 @@ module ReactOnRailsHelper
112
113
  component_name: react_component_name,
113
114
  props: props,
114
115
  trace: trace(options),
115
- expect_turbolinks: turbolinks_loaded,
116
116
  dom_id: dom_id
117
117
  }
118
118
 
@@ -146,24 +146,27 @@ module ReactOnRailsHelper
146
146
  HTML
147
147
  end
148
148
 
149
- # Deprecated: Use `redux_store` via including ReactOnRails::Controller in your controller and calling
150
- # redux_store.
151
- #
152
149
  # Separate initialization of store from react_component allows multiple react_component calls to
153
150
  # use the same Redux store.
154
151
  #
155
152
  # store_name: name of the store, corresponding to your call to ReactOnRails.registerStores in your
156
153
  # JavaScript code.
157
154
  # props: Ruby Hash or JSON string which contains the properties to pass to the redux store.
158
- def redux_store(store_name, props = {})
159
- warn "[DEPRECATION] `redux_store` within a view is deprecated. Please move to call "\
160
- "to redux store to your controller action."
155
+ # Options
156
+ # defer: false -- pass as true if you wish to render this below your component.
157
+ def redux_store(store_name, props: {}, defer: false)
161
158
  redux_store_data = { store_name: store_name,
162
159
  props: props }
163
- @registered_stores ||= []
164
- @registered_stores << redux_store_data
165
-
166
- render_redux_store_data(redux_store_data)
160
+ if defer
161
+ @registered_stores_defer_render ||= []
162
+ @registered_stores_defer_render << redux_store_data
163
+ "YOU SHOULD NOT SEE THIS ON YOUR VIEW -- Uses as a code block, like <% redux_store %> "\
164
+ "and not <%= redux store %>"
165
+ else
166
+ @registered_stores ||= []
167
+ @registered_stores << redux_store_data
168
+ render_redux_store_data(redux_store_data)
169
+ end
167
170
  end
168
171
 
169
172
  # Place this view helper (no parameters) at the end of your shared layout. This tell
@@ -172,8 +175,8 @@ module ReactOnRailsHelper
172
175
  # client side rendering of this hydration data, which is a hidden div with a matching class
173
176
  # that contains a data props.
174
177
  def redux_store_hydration_data
175
- return if @registered_stores_via_controller.blank?
176
- @registered_stores_via_controller.reduce("") do |accum, redux_store_data|
178
+ return if @registered_stores_defer_render.blank?
179
+ @registered_stores_defer_render.reduce("") do |accum, redux_store_data|
177
180
  accum << render_redux_store_data(redux_store_data)
178
181
  end.html_safe
179
182
  end
@@ -300,10 +303,10 @@ module ReactOnRailsHelper
300
303
  end
301
304
 
302
305
  def initialize_redux_stores
303
- return "" unless @registered_stores.present? || @registered_stores_via_controller.present?
306
+ return "" unless @registered_stores.present? || @registered_stores_defer_render.present?
304
307
  declarations = "var reduxProps, store, storeGenerator;\n"
305
308
 
306
- all_stores = (@registered_stores || []) + (@registered_stores_via_controller || [])
309
+ all_stores = (@registered_stores || []) + (@registered_stores_defer_render || [])
307
310
 
308
311
  result = all_stores.each_with_object(declarations) do |redux_store_data, memo|
309
312
  store_name = redux_store_data[:store_name]
@@ -43,7 +43,7 @@ See the next section for a sample webpack.server.rails.config.js.
43
43
  ```javascript
44
44
  entry: ['./app/startup/serverRegistration'],
45
45
  ```
46
- 3. Ensure the name of your ouput file (shown [here](https://github.com/shakacode/react-webpack-rails-tutorial/blob/537c985dc82faee333d80509343ca32a3965f9dd/client/webpack.server.rails.config.js#L9)) of your server bundle corresponds to the configuration of the gem. The default path is `app/assets/javascripts/generated`. See below for customization of configuration variables.
46
+ 3. Ensure the name of your ouput file (shown [here](https://github.com/shakacode/react-webpack-rails-tutorial/blob/537c985dc82faee333d80509343ca32a3965f9dd/client/webpack.server.rails.config.js#L9)) of your server bundle corresponds to the configuration of the gem. The default path is `app/assets/webpack`. See below for customization of configuration variables.
47
47
  4. Expose `React` in your webpack config, like [this](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/webpack.server.rails.build.config.js#L54-L55)
48
48
 
49
49
  ```javascript
@@ -65,7 +65,7 @@ module.exports = {
65
65
  entry: ['./app/startup/serverRegistration'],
66
66
  output: {
67
67
  filename: 'server-bundle.js',
68
- path: '../app/assets/javascripts/generated',
68
+ path: '../app/assets/webpack',
69
69
 
70
70
  // CRITICAL to set libraryTarget: 'this' for enabling Rails to find the exposed modules IF you
71
71
  // use the "expose" webpackfunctionality. See startup/serverRegistration.jsx.
@@ -10,7 +10,7 @@ ReactOnRails.configure do |config|
10
10
  # Client bundles are configured in application.js
11
11
  # Server bundle is a single file for all server rendering of components.
12
12
  # Set the server_bundle_js_file to "" if you know that you will not be server rendering.
13
- config.server_bundle_js_file = "app/assets/javascripts/generated/server.js" # This is the default
13
+ config.server_bundle_js_file = "server-bundle.js" # This is the default
14
14
 
15
15
  # Below options can be overriden by passing to the helper method.
16
16
  config.prerender = false # default is false
@@ -13,10 +13,12 @@ You can pass an RSpec metatag as an optional second parameter to this helper met
13
13
 
14
14
  Please take note of the following:
15
15
  - This utility assumes your build tasks for the static generated files are `npm run build:client` and `npm run build:server` and do not have the `--watch` option enabled.
16
- - By default, the webpack processes look for the `app/assets/javascripts/generated` and `app/assets/stylesheets/generated` folders. If these folders are missing, are empty, or contain files with `mtime`s older than any of the files in your `client` folder, the helper will recompile your assets. You can override this inside of `config/initializers/react_on_rails.rb` by passing an array of filepaths (relative to the root of the app) to the `generated_assets_dirs` configuration option.
16
+ - By default, the webpack processes look for the `app/assets/webpack` folders. If this folder is missing, is empty, or contains files with `mtime`s older than any of the files in your `client` folder, the helper will recompile your assets. You can override this inside of `config/initializers/react_on_rails.rb` by passing a filepath (relative to the root of the app) to the `generated_assets_dir` configuration option.
17
17
 
18
18
  If you want to speed up the re-compiling process, you can call `npm run build:dev:client` (and `npm run build:dev:server` if doing server rendering) to have webpack run in "watch" mode and recompile these files in the background, which will be much faster when making incremental changes than compiling from scratch.
19
19
 
20
+ [spec/dummy](../../spec/dummy) contains examples of how to set the proc files for this purpose.
21
+
20
22
  If you want to use a testing framework other than RSpec, please submit let us know on the changes you need to do and we'll update the docs.
21
23
 
22
24
  ![2016-01-27_02-36-43](https://cloud.githubusercontent.com/assets/1118459/12611951/7c56d070-c4a4-11e5-8a80-9615f99960d9.png)
@@ -13,14 +13,15 @@ the JavaScript and stylesheets are cached by the browser, as they will still req
13
13
  1. Include the gem "turbolinks".
14
14
  1. Included the proper "track" tags when you include the javascript and stylesheet:
15
15
  ```erb
16
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
17
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
16
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => 'reload' %>
17
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => 'reload' %>
18
18
  ```
19
+ NOTE: for Turbolinks 2.x, use 'data-turbolinks-track' => true
19
20
  1. Add turbolinks to your `application.js` file:
20
21
  ```javascript
21
22
  //= require turbolinks
22
23
  ```
23
- Note, in the future, we might change to installing this via npm.
24
+ Note, in the future, we will change to installing this via npm.
24
25
 
25
26
  ## Turbolinks 5
26
27
  Turbolinks 5 is now being supported. React on Rails will automatically detect which version of Turbolinks you are using and use the correct event handlers.
@@ -16,7 +16,7 @@ It's critical to configure your IDE/editor to ignore certain directories. Otherw
16
16
  * /gen-examples
17
17
  * /node_package/lib
18
18
  * /node_modules
19
- * /spec/dummy/app/assets/javascripts/generated
19
+ * /spec/dummy/app/assets/webpack
20
20
  * /spec/dummy/log
21
21
  * /spec/dummy/node_modules
22
22
  * /spec/dummy/tmp
@@ -127,7 +127,7 @@ Completed all linting
127
127
 
128
128
  It's super important to exclude certain directories from RubyMine or else it will slow to a crawl as it tries to parse all the npm files.
129
129
 
130
- * `app/assets/javascripts/generated`
130
+ * `app/assets/webpack`
131
131
  * `client/node_modules`
132
132
 
133
133
  <img src="http://forum.shakacode.com/uploads/default/original/1X/a1b3e1146d86915f7d5d1c89548e81ec208458cc.png" width="338" height="500">
@@ -59,7 +59,7 @@ module ReactOnRails
59
59
  node_modules
60
60
 
61
61
  # Generated js bundles
62
- /app/assets/javascripts/generated/*
62
+ /app/assets/webpack/*
63
63
  DATA
64
64
 
65
65
  if dest_file_exists?(".gitignore")
@@ -74,11 +74,11 @@ module ReactOnRails
74
74
  // DO NOT REQUIRE jQuery or jQuery-ujs in this file!
75
75
  // DO NOT REQUIRE TREE!
76
76
 
77
- // CRITICAL that generated/vendor-bundle must be BEFORE bootstrap-sprockets and turbolinks
77
+ // CRITICAL that vendor-bundle must be BEFORE bootstrap-sprockets and turbolinks
78
78
  // since it is exposing jQuery and jQuery-ujs
79
79
 
80
- //= require generated/vendor-bundle
81
- //= require generated/app-bundle
80
+ //= require vendor-bundle
81
+ //= require app-bundle
82
82
 
83
83
  DATA
84
84
 
@@ -161,22 +161,26 @@ module ReactOnRails
161
161
  template("base/base/lib/tasks/assets.rake.tt", "lib/tasks/assets.rake")
162
162
  end
163
163
 
164
+ ASSETS_RB_APPEND = <<-DATA.strip_heredoc
165
+ # Add client/assets/ folders to asset pipeline's search path.
166
+ # If you do not want to move existing images and fonts from your Rails app
167
+ # you could also consider creating symlinks there that point to the original
168
+ # rails directories. In that case, you would not add these paths here.
169
+ Rails.application.config.assets.paths << Rails.root.join("client", "assets", "stylesheets")
170
+ Rails.application.config.assets.paths << Rails.root.join("client", "assets", "images")
171
+ Rails.application.config.assets.paths << Rails.root.join("client", "assets", "fonts")
172
+ Rails.application.config.assets.precompile += %w( server-bundle.js )
173
+
174
+ # Add folder with webpack generated assets to assets.paths
175
+ Rails.application.config.assets.paths << Rails.root.join("app", "assets", "webpack")
176
+ DATA
177
+
164
178
  def append_to_assets_initializer
165
- data = <<-DATA.strip_heredoc
166
- # Add client/assets/ folders to asset pipeline's search path.
167
- # If you do not want to move existing images and fonts from your Rails app
168
- # you could also consider creating symlinks there that point to the original
169
- # rails directories. In that case, you would not add these paths here.
170
- Rails.application.config.assets.paths << Rails.root.join("client", "assets", "stylesheets")
171
- Rails.application.config.assets.paths << Rails.root.join("client", "assets", "images")
172
- Rails.application.config.assets.paths << Rails.root.join("client", "assets", "fonts")
173
- Rails.application.config.assets.precompile += %w( generated/server-bundle.js )
174
- DATA
175
179
  assets_intializer = File.join(destination_root, "config/initializers/assets.rb")
176
180
  if File.exist?(assets_intializer)
177
- append_to_file(assets_intializer, data)
181
+ append_to_file(assets_intializer, ASSETS_RB_APPEND)
178
182
  else
179
- create_file(assets_intializer, data)
183
+ create_file(assets_intializer, ASSETS_RB_APPEND)
180
184
  end
181
185
  end
182
186
 
@@ -68,7 +68,7 @@ module ReactOnRails
68
68
  def add_bootstrap_sprockets_to_application_js
69
69
  data = <<-DATA.strip_heredoc
70
70
 
71
- // bootstrap-sprockets depends on generated/vendor-bundle for jQuery.
71
+ // bootstrap-sprockets depends on vendor-bundle for jQuery.
72
72
  //= require bootstrap-sprockets
73
73
 
74
74
  DATA
@@ -1,4 +1,4 @@
1
1
  web: rails s
2
2
  # TODO: MIGRATE from tutorial
3
- client: sh -c 'rm app/assets/javascripts/generated/* || true && cd client && npm run build:dev:client'
3
+ client: sh -c 'rm app/assets/webpack/* || true && cd client && npm run build:dev:client'
4
4
  <%- if options.server_rendering? %>server: sh -c 'cd client && npm run build:dev:server'<%- end %>
@@ -1,3 +1,3 @@
1
1
  web: rails s
2
- client: sh -c 'rm app/assets/javascripts/generated/* || true && cd client && npm run build:dev:client'
2
+ client: sh -c 'rm app/assets/webpack/* || true && cd client && npm run build:dev:client'
3
3
  <%- if options.server_rendering? %>server: sh -c 'cd client && npm run build:dev:server'<%- end %>
@@ -10,7 +10,7 @@ const devBuild = process.env.NODE_ENV !== 'production';
10
10
 
11
11
  config.output = {
12
12
  filename: '[name]-bundle.js',
13
- path: '../app/assets/javascripts/generated',
13
+ path: '../app/assets/webpack',
14
14
  };
15
15
 
16
16
  // You can add entry points specific to rails here
@@ -2,11 +2,21 @@
2
2
  ReactOnRails.configure do |config|
3
3
  # Client bundles are configured in application.js
4
4
 
5
+ # Directory where your generated assets go
6
+ config.generated_assets_dir = File.join(%w(app assets webpack))
7
+
8
+ # Define the files for we need to check for webpack compilation when running tests
9
+ <%- if options.server_rendering? %>
10
+ config.webpack_generated_files = %w( client-bundle.js server-bundle.js )
11
+ <% else %>
12
+ config.webpack_generated_files = %w( client-bundle.js )
13
+ <%- end %>
14
+
5
15
  # Server rendering:
6
16
  # Server bundle is a single file for all server rendering of components.
7
17
  # Set the server_bundle_js_file to "" if you know that you will not be server rendering.
8
18
  <%- if options.server_rendering? %>
9
- config.server_bundle_js_file = "app/assets/javascripts/generated/server-bundle.js"
19
+ config.server_bundle_js_file = "server-bundle.js"
10
20
  <% else %>
11
21
  config.server_bundle_js_file = ""
12
22
  <%- end %>