react_on_rails 13.4.0 → 14.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -2
- data/Gemfile.development_dependencies +10 -9
- data/Gemfile.lock +434 -0
- data/README.md +25 -17
- data/lib/generators/react_on_rails/base_generator.rb +3 -2
- data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +1 -1
- data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +2 -2
- data/lib/generators/react_on_rails/templates/dev_tests/spec/system/hello_world_spec.rb +1 -1
- data/lib/react_on_rails/configuration.rb +39 -25
- data/lib/react_on_rails/git_utils.rb +3 -3
- data/lib/react_on_rails/helper.rb +3 -4
- data/lib/react_on_rails/json_output.rb +0 -17
- data/lib/react_on_rails/locales/base.rb +4 -4
- data/lib/react_on_rails/locales/to_js.rb +1 -1
- data/lib/react_on_rails/packs_generator.rb +5 -6
- data/lib/react_on_rails/react_component/render_options.rb +1 -1
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +9 -9
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +3 -3
- data/lib/react_on_rails/test_helper.rb +2 -2
- data/lib/react_on_rails/utils.rb +2 -8
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +2 -2
- data/lib/react_on_rails/webpacker_utils.rb +6 -0
- data/lib/tasks/assets.rake +1 -1
- data/react_on_rails.gemspec +4 -4
- metadata +5 -132
- data/.bookignore +0 -15
- data/.circleci/config.yml +0 -338
- data/.coveralls.yml +0 -1
- data/.dockerignore +0 -2
- data/.eslintignore +0 -17
- data/.eslintrc +0 -53
- data/.github/FUNDING.yml +0 -1
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -19
- data/.github/workflows/lint-js-and-ruby.yml +0 -54
- data/.github/workflows/main.yml +0 -183
- data/.github/workflows/package-js-tests.yml +0 -35
- data/.github/workflows/rspec-package-specs.yml +0 -46
- data/.gitignore +0 -33
- data/.npmignore +0 -22
- data/.prettierignore +0 -14
- data/.prettierrc +0 -20
- data/.rspec +0 -2
- data/.rubocop.yml +0 -134
- data/.scss-lint.yml +0 -205
- data/.travis.yml +0 -61
- data/book.json +0 -18
- data/docs/additional-details/generator-details.md +0 -56
- data/docs/additional-details/manual-installation-overview.md +0 -30
- data/docs/additional-details/migrating-from-react-rails.md +0 -17
- data/docs/additional-details/recommended-project-structure.md +0 -69
- data/docs/additional-details/tips-for-usage-with-sp6.md +0 -15
- data/docs/additional-details/updating-dependencies.md +0 -31
- data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +0 -10
- data/docs/api/javascript-api.md +0 -99
- data/docs/api/redux-store-api.md +0 -102
- data/docs/api/view-helpers-api.md +0 -133
- data/docs/contributor-info/errors-with-hooks.md +0 -45
- data/docs/contributor-info/generator-testing.md +0 -11
- data/docs/contributor-info/linters.md +0 -68
- data/docs/contributor-info/pull-requests.md +0 -42
- data/docs/contributor-info/releasing.md +0 -76
- data/docs/deployment/elastic-beanstalk.md +0 -63
- data/docs/deployment/heroku-deployment.md +0 -39
- data/docs/getting-started.md +0 -196
- data/docs/guides/client-vs-server-rendering.md +0 -27
- data/docs/guides/configuration.md +0 -289
- data/docs/guides/deployment.md +0 -5
- data/docs/guides/file-system-based-automated-bundle-generation.md +0 -197
- data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +0 -104
- data/docs/guides/how-react-on-rails-works.md +0 -44
- data/docs/guides/how-to-conditionally-server-render-based-on-device-type.md +0 -40
- data/docs/guides/how-to-use-different-files-for-client-and-server-rendering.md +0 -98
- data/docs/guides/i18n.md +0 -87
- data/docs/guides/installation-into-an-existing-rails-app.md +0 -66
- data/docs/guides/minitest-configuration.md +0 -31
- data/docs/guides/rails-webpacker-react-integration-options.md +0 -213
- data/docs/guides/react-on-rails-overview.md +0 -29
- data/docs/guides/react-server-rendering.md +0 -32
- data/docs/guides/render-functions-and-railscontext.md +0 -205
- data/docs/guides/rspec-configuration.md +0 -73
- data/docs/guides/tutorial.md +0 -371
- data/docs/guides/upgrading-react-on-rails.md +0 -304
- data/docs/guides/webpack-configuration.md +0 -42
- data/docs/home.md +0 -23
- data/docs/javascript/angular-js-integration-migration.md +0 -28
- data/docs/javascript/asset-pipeline.md +0 -12
- data/docs/javascript/capistrano-deployment.md +0 -18
- data/docs/javascript/code-splitting.md +0 -165
- data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +0 -10
- data/docs/javascript/credits.md +0 -10
- data/docs/javascript/foreman-issues.md +0 -15
- data/docs/javascript/images.md +0 -57
- data/docs/javascript/node-dependencies-and-npm.md +0 -19
- data/docs/javascript/react-and-redux.md +0 -36
- data/docs/javascript/react-helmet.md +0 -100
- data/docs/javascript/react-router.md +0 -90
- data/docs/javascript/server-rendering-tips.md +0 -55
- data/docs/javascript/troubleshooting-when-using-shakapacker.md +0 -77
- data/docs/javascript/troubleshooting-when-using-webpacker.md +0 -90
- data/docs/javascript/webpack-v1-notes.md +0 -23
- data/docs/javascript/webpack.md +0 -22
- data/docs/misc/articles.md +0 -20
- data/docs/misc/code_of_conduct.md +0 -13
- data/docs/misc/doctrine.md +0 -77
- data/docs/misc/style.md +0 -33
- data/docs/misc/tips.md +0 -10
- data/docs/outdated/deferred-rendering.md +0 -39
- data/docs/outdated/rails-assets-relative-paths.md +0 -195
- data/docs/outdated/rails-assets.md +0 -77
- data/docs/outdated/rails3.md +0 -9
- data/docs/rails/convert-rails-5-api-only-app.md +0 -19
- data/docs/rails/rails-engine-integration.md +0 -32
- data/docs/rails/rails_view_rendering_from_inline_javascript.md +0 -36
- data/docs/rails/turbolinks.md +0 -124
- data/docs/react-on-rails-pro/react-on-rails-pro.md +0 -43
- data/docs/testimonials/hvmn.md +0 -25
- data/docs/testimonials/resortpass.md +0 -13
- data/docs/testimonials/testimonials.md +0 -28
- data/jest.config.js +0 -4
- data/package-scripts.yml +0 -49
- data/package.json +0 -96
- data/rakelib/docker.rake +0 -26
- data/rakelib/dummy_apps.rake +0 -30
- data/rakelib/example_type.rb +0 -96
- data/rakelib/examples.rake +0 -64
- data/rakelib/examples_config.yml +0 -14
- data/rakelib/lint.rake +0 -30
- data/rakelib/node_package.rake +0 -15
- data/rakelib/release.rake +0 -92
- data/rakelib/run_rspec.rake +0 -103
- data/rakelib/task_helpers.rb +0 -62
- data/script/bootstrap +0 -33
- data/script/release +0 -3
- data/script/setup +0 -23
- data/script/test +0 -38
- data/webpackConfigLoader.js +0 -71
- data/yarn.lock +0 -7010
@@ -1,195 +0,0 @@
|
|
1
|
-
*Note: this doc reflects using Sprockets for assets and has not been updated for Shakapacker or rails/webpacker*
|
2
|
-
|
3
|
-
# Using Webpack bundled assets with the Rails Asset Pipeline
|
4
|
-
|
5
|
-
**If you're looking to use assets in your react components, look no further. This doc is for you.**
|
6
|
-
|
7
|
-
As most of you know, when you spin up a Rails application all of your asset files that live within your `app/assets/` directory will be added into your application's Asset Pipeline. If you would like to view any of these assets (most commonly you'd want to view images), run your rails server in development mode and in a browser visit a url similar to: `localhost:3000/assets/sample_image.png`. In this case, if I had an image `sample_image.png` in my `app/assets/images/` directory, visiting the url `localhost:3000/assets/sample_image.png` in a browser would display the image to me. Meaning that `/assets/sample_image.png` is my path to that individual asset.
|
8
|
-
|
9
|
-
## The Problem
|
10
|
-
|
11
|
-
Sometimes we would like to use images directly in our react components or even component specific CSS. This can cause problems because it is difficult to maintain the relative path to assets in our pipeline. Normally, we would use erb to get around this, using something like `<img src="<%= asset_path('my-image.png') %>" />`. Unfortunately, that will not play well with webpack.
|
12
|
-
|
13
|
-
Now we could always just place these assets in our `app/assets/` directory like normal and then reference them in our react with things like `<img src="/assets/asset-name.ext" />`, and that would work! But that also will move this image out of our client side app, which isn't always ideal. Also hardcoding the path to an asset isn't a good approach considering file paths can always change, and that would then require a source code change. That's just no bueno.
|
14
|
-
|
15
|
-
So how do we get around this? And find the relative paths to our assets without hardcoding the paths?
|
16
|
-
|
17
|
-
## The Solution: The lowdown on Webpack's url-loader & file-loader, outputPaths and publicPaths
|
18
|
-
|
19
|
-
Loaders are an incredibly useful part of Webpack. Simply put, they allow you to load and bundle different types of sources/files (you can load anything from images, CSS, to CoffeeScript).
|
20
|
-
|
21
|
-
##### Url Loader vs. File Loader
|
22
|
-
|
23
|
-
Two very common, and quite useful, Webpack loaders are the [url-loader](https://github.com/webpack-contrib/url-loader) and the [file-loader](https://github.com/webpack-contrib/file-loader). They allow you to load and access files in an easy manner. Both of these loaders are incredibly similar to one another, and in fact work together to accomplish their goals, with a very slight difference. The url-loader will load any file(s) and when accessed, will return a Data Url that can be used to access the file(s) (commonly used to inline images). File-loader on the other hand, will bundle and output the file(s) to a desired directory so they can live in the assets on your webserver along with your outputted webpack bundle. These bundled assets can then be accessed by their public paths, making it very easy to include and use them in your JavaScript code.
|
24
|
-
|
25
|
-
The url-loader is great to use for smaller images! It is most commonly used with a set byte limit on the size of the files that can be loaded. When this is the case, anything below the byte limit will be loaded and returned as a Data Url. Anything that exceeds the byte limit, will delegate to file-loader for loading, passing any set query parameters as well to file-loader (if that sounds like gibberish right now, don't worry. You'll learn all about it soon!).
|
26
|
-
|
27
|
-
The benefit of using url-loader first, and falling back on file-loader, is that the use of Data Urls saves HTTP Requests that need to be made to fetch files. That is very important in regards to how fast a webpage will load. Generally speaking, the less HTTP requests that need to be made, the faster a page will load. For more information about usage, and the pros & cons of Data Urls read [here](https://css-tricks.com/data-uris/).
|
28
|
-
|
29
|
-
Note: _For the rest of this doc, we will be using file-loader. This is because its usage can be a little bit trickier and it is used as url-loader's back up. Keep in mind that the usage for the two are EXTREMELY similar. For more info about the url-loader's usage, check out its configuration for the `react_on_rails` sample app [here](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/webpack.client.base.config.js) (specifically lines 82-84)._
|
30
|
-
|
31
|
-
##### Configuring Webpack with file-loader
|
32
|
-
|
33
|
-
Once you have added file-loader (or whatever loader you would like to use) to your project, you can start configuring your `webpack.config.js` file to bundle these assets. Inside your `module["loaders"]` list you will add a new object to represent your loader. This loader will include a few attributes:
|
34
|
-
|
35
|
-
1. `test`: a regular expression that specifies the types of files that can be loaded.
|
36
|
-
2. `loader`: the name of the loader you will be using (in this doc we will be using [file-loader](https://github.com/webpack-contrib/file-loader))
|
37
|
-
3. `query`: query parameters are additional configuration options that get passed to the loader. This can either be appended to your `loader` attribute like follows:
|
38
|
-
|
39
|
-
|
40
|
-
```javascript
|
41
|
-
loader: "file-loader?name=[name].[ext]"
|
42
|
-
```
|
43
|
-
|
44
|
-
or as a JSON object:
|
45
|
-
|
46
|
-
```javascript
|
47
|
-
query: {
|
48
|
-
name: "[name].[ext]"
|
49
|
-
}
|
50
|
-
```
|
51
|
-
|
52
|
-
both of these two example above do the exact same thing, just using different syntaxes. For the rest of this doc we will be using the JSON object style. For more information about webpack loaders, read [this](https://webpack.github.io/docs/using-loaders.html).
|
53
|
-
|
54
|
-
_For the sake of this doc, we're also going to add a `resolve["alias"]` inside our webpack.config to make it easier to include our assets in our jsx files. In `resolve["alias"]`, simply add:_
|
55
|
-
|
56
|
-
```javascript
|
57
|
-
'assets': path.resolve('./app/assets')
|
58
|
-
```
|
59
|
-
|
60
|
-
##### Configuring your file-loader Query Parameters
|
61
|
-
|
62
|
-
The first property we'll want to set is our file's resulting name after bundling. For now we're just going to use:
|
63
|
-
|
64
|
-
```javascript
|
65
|
-
name: "[name][md5:hash].[ext]"
|
66
|
-
```
|
67
|
-
|
68
|
-
This will just set the name to the file's original name + a md5 digested hash + the extension of the original file (.png, .jpg, etc).
|
69
|
-
|
70
|
-
Next we'll set the outputPath for our files. This is the directory we want the files to be placed in after webpack runs. When Webpack runs with file-loader, all files (in this case assets) that have been used in the bundled JavaScript will be bundled and outputted to the output destination. **Keep in mind that react_on_rails outputs by default to the `app/assets/webpack/` directory so when we specify the outputPath here it will be relative the `app/assets/webpack` directory.** You can set the outputPath to whatever you want, in this example we will add it to a directory `/app/assets/webpack/webpack-assets/`, and here's how we would do that:
|
71
|
-
|
72
|
-
```javascript
|
73
|
-
outputPath: "webpack-assets/"
|
74
|
-
```
|
75
|
-
|
76
|
-
Note: _You can output these files in the asset pipeline wherever you see fit. My preference is outputting somewhere inside the `app/assets/webpack/` directory just because anything in this directory is already ignored by git due to the react_on_rails generated gitignore, meaning they will not be added by git twice! (once in your `client/app/assets/` and once in your outputted path after webpack bundling)_
|
77
|
-
|
78
|
-
Lastly, we will set the publicPath to our file(s). This will be the endpoint on our rails web server that you can visit to reach the asset (if you don't know how this works, read the [intro](#using-webpack-bundled-assets-with-the-rails-asset-pipeline)). If you've been following the previous steps, you know that we set our outputPath for our assets to be absolute at `app/assets/webpack/webpack-assets/`, which your rails app should end up hosting at `/assets/webpack-assets/file-name+hash.ext` when the server is run.
|
79
|
-
|
80
|
-
Note: _If you're having a hard time figuring out what an asset's path will be on your rails server, simply run `rake assets:precompile` and `cd public/`. The path from there to your file will then be the path/url on your web server to that asset. On top of this, it is also a good idea to check out [this doc](https://www.shakacode.com/react-on-rails/docs/outdated/rails-assets/) to understand how `react_on_rails` allows us to access these files after precompilation, when Rails applies another hash onto the asset._
|
81
|
-
|
82
|
-
Our publicPath setting will match the path to our outputted assets on our rails web server. Given our assets in this example will be outputted to `/app/assets/webpack/webpack-assets/` and hosted at `/assets/webpack-assets/`, our publicPath would be:
|
83
|
-
|
84
|
-
```javascript
|
85
|
-
publicPath: "/assets/webpack-assets/"
|
86
|
-
```
|
87
|
-
|
88
|
-
Voila! Your webpack setup is complete.
|
89
|
-
|
90
|
-
##### Adding/Using `client/` Assets
|
91
|
-
|
92
|
-
Now for the fun part, we actually get to use our client assets now. The first thing you'll want to do is create an assets directory inside your client directory. The best place for this directory is probably at `client/app/assets`. Put any assets you want in there, images, stylesheets, whatever. Now that the assets are in place, we can simply `import` or `require` them in our jsx files for use in our components. For example:
|
93
|
-
|
94
|
-
```javascript
|
95
|
-
import myImage from 'assets/images/my-image.png'; // This uses the assets alias we created earlier to map to the client/app/assets/ directory followed by `images/my-image.png`
|
96
|
-
|
97
|
-
export default class MyImageBox extends React.Component {
|
98
|
-
constructor(props, context) {
|
99
|
-
super(props, context);
|
100
|
-
}
|
101
|
-
|
102
|
-
render() {
|
103
|
-
return <img src={myImage} />
|
104
|
-
}
|
105
|
-
}
|
106
|
-
```
|
107
|
-
|
108
|
-
`myImage` in the example above will resolve to the path of that asset on the web server. Therefore using it as an img's source would then properly display the image/assets when this react component is rendered.
|
109
|
-
|
110
|
-
Note: **Any assets in our `client/` directory that are not imported/required for use in our jsx files will NOT be bundled and outputted by webpack.**
|
111
|
-
|
112
|
-
## Summary: Welcome people who are tired of reading
|
113
|
-
|
114
|
-
If you've read this far, you probably have a grip on everything. If you didn't, and want a condensed version, here you go:
|
115
|
-
|
116
|
-
- Add webpack's file-loader to your project
|
117
|
-
- Add a new loader module in your webpack.config.js file
|
118
|
-
- Set this loader's test attribute to a regex of the file extensions you would like to load
|
119
|
-
- Set the loader attribute to "file-loader"
|
120
|
-
- Set name to something like `"[name][md5:hash].[ext]"`
|
121
|
-
- Set outputPath attribute to directory of choice, relative to `app/assets/webpack` directory
|
122
|
-
- Set publicPath attribute, this should be the same as where the rails asset pipeline will serve your asset(s) on the server. See [this](#configuring-your-file-loader-query-parameters) for more info.
|
123
|
-
- Add assets directory in `client/app/`, and place whatever you would like in there
|
124
|
-
- Import or Require these files in your jsx and use them all you want!
|
125
|
-
|
126
|
-
### Here's a full example of a webpack.config.js configured with file-loader to load images:
|
127
|
-
|
128
|
-
```javascript
|
129
|
-
const webpack = require('webpack');
|
130
|
-
const path = require('path');
|
131
|
-
|
132
|
-
const devBuild = process.env.NODE_ENV !== 'production';
|
133
|
-
const nodeEnv = devBuild ? 'development' : 'production';
|
134
|
-
|
135
|
-
module.exports = {
|
136
|
-
entry: [
|
137
|
-
'./app/bundles/HelloWorld/startup/registration',
|
138
|
-
],
|
139
|
-
|
140
|
-
output: {
|
141
|
-
filename: 'hello-world-bundle.js',
|
142
|
-
path: '../app/assets/webpack'
|
143
|
-
},
|
144
|
-
|
145
|
-
resolve: {
|
146
|
-
extensions: ['', '.js', '.jsx'],
|
147
|
-
alias: {
|
148
|
-
assets: path.resolve('./app/assets'), // Makes it easier to reference our assets in jsx files
|
149
|
-
react: path.resolve('./node_modules/react'),
|
150
|
-
'react-dom': path.resolve('./node_modules/react-dom'),
|
151
|
-
},
|
152
|
-
},
|
153
|
-
|
154
|
-
plugins: [
|
155
|
-
new webpack.DefinePlugin({
|
156
|
-
'process.env': {
|
157
|
-
NODE_ENV: JSON.stringify(nodeEnv),
|
158
|
-
}
|
159
|
-
})
|
160
|
-
],
|
161
|
-
module: {
|
162
|
-
rules: [
|
163
|
-
{
|
164
|
-
test: /\.jsx?$/,
|
165
|
-
loader: 'babel-loader',
|
166
|
-
exclude: /node_modules/,
|
167
|
-
},
|
168
|
-
{
|
169
|
-
test: require.resolve('react'),
|
170
|
-
use: {
|
171
|
-
loader: 'imports-loader',
|
172
|
-
options: {
|
173
|
-
shim: 'es5-shim/es5-shim',
|
174
|
-
sham: 'es5-shim/es5-sham',
|
175
|
-
},
|
176
|
-
}
|
177
|
-
},
|
178
|
-
{
|
179
|
-
// The important stuff
|
180
|
-
test: /\.(jpg|jpeg|png)(\?.*)?$/, // Load only .jpg .jpeg, and .png files
|
181
|
-
use: {
|
182
|
-
loader: 'file-loader',
|
183
|
-
options: {
|
184
|
-
name: '[name][md5:hash].[ext]', // Name of bundled asset
|
185
|
-
outputPath: 'webpack-assets/', // Output location for assets. Final: `app/assets/webpack/webpack-assets/`
|
186
|
-
publicPath: '/assets/webpack-assets/' // Endpoint asset can be found at on Rails server
|
187
|
-
}
|
188
|
-
}
|
189
|
-
}
|
190
|
-
]
|
191
|
-
}
|
192
|
-
};
|
193
|
-
```
|
194
|
-
|
195
|
-
If you'd like to understand how react_on_rails handles these bundled assets after asset precompilation and in production mode, check out: [Rails Assets](https://www.shakacode.com/react-on-rails/docs/outdated/rails-assets/).
|
@@ -1,77 +0,0 @@
|
|
1
|
-
# Rails assets and the Extract Text Plugin
|
2
|
-
|
3
|
-
*This doc needs updating for the use of Shakapacker or rails/webpacker with React on Rails*
|
4
|
-
|
5
|
-
The [Webpack file loader](https://github.com/webpack/file-loader) copies referenced files to
|
6
|
-
the destination output directory, with an MD5 hash. The other term for this is a "digest".
|
7
|
-
|
8
|
-
> By default the filename of the resulting file is the MD5 hash of the file's contents with
|
9
|
-
the original extension of the required resource.
|
10
|
-
|
11
|
-
The most common use cases for Webpack processed files are images used for backgrounds in
|
12
|
-
CSS and fonts for CSS. However, this applies to any file that might be processed using the
|
13
|
-
Webpack file loader.
|
14
|
-
|
15
|
-
## The Problem
|
16
|
-
To understand the problem, it helps to read this article:
|
17
|
-
[What is fingerprinting and why should I care](http://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care-questionmark)
|
18
|
-
Basically, when Rails prepares assets for production deployments, it also adds a digest
|
19
|
-
to the file names. E.g., `img1.jpg` becomes `img1-dbu097452jf2v2.jpg`.
|
20
|
-
|
21
|
-
When compiling its native css Rails transforms all urls and links to digested
|
22
|
-
versions, i.e. `background-image: image-url(img1.jpg)` becomes
|
23
|
-
`background-image: url(img1-dbu097452jf2v2.jpg)`. However this doesn't happen for js and
|
24
|
-
css files compiled by webpack on the client side, because they don't use
|
25
|
-
`image-url` and `asset-url`. Without some fix, these assets would fail to load.
|
26
|
-
|
27
|
-
When Webpack's client JavaScript uses images in render methods, e.g. `<img src='...' />` or
|
28
|
-
in css, e.g. `background-image: url(...)` The code (such as the CSS) generated by the Webpack
|
29
|
-
will have the Webpack digested name (MD5 hash). Since the Webpack generated CSS expects
|
30
|
-
just one level of "digesting", this "double-digesting" from Rails will cause such these assets
|
31
|
-
fail to load.
|
32
|
-
|
33
|
-
_If you are interested in learning how to use assets in your React components, read this doc: [Webpack, the Asset Pipeline, and Using Assets w/ React](https://www.shakacode.com/react-on-rails/docs/outdated/rails-assets-relative-paths/)_
|
34
|
-
|
35
|
-
## The Solution: Symlink Original File Names to New File Names
|
36
|
-
_Note, this solution was removed in v14. If you're intersted in this symlink solution, please create
|
37
|
-
a github issue._
|
38
|
-
|
39
|
-
## Example from /spec/dummy
|
40
|
-
|
41
|
-
```
|
42
|
-
cd spec/dummy
|
43
|
-
RAILS_ENV=production bundle exec rake assets:precompile
|
44
|
-
rails s -e production
|
45
|
-
```
|
46
|
-
|
47
|
-
You will see this. This shows how the file names output by rails. Note the original names after
|
48
|
-
being processed by Webpack are just MD5's.
|
49
|
-
|
50
|
-
```
|
51
|
-
I, [2016-07-17T23:46:56.301981 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/server-bundle-42935dea382802a27e91b7df444a2813f74b4e6a0fce5606d863aaa10c0623d7.js
|
52
|
-
I, [2016-07-17T23:46:56.305649 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/server-bundle-42935dea382802a27e91b7df444a2813f74b4e6a0fce5606d863aaa10c0623d7.js.gz
|
53
|
-
I, [2016-07-17T23:46:56.370390 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/application_static-dfa728160c3cdebc633c2f6fb3823411530b307044f4dfe460790eef00b4e421.js
|
54
|
-
I, [2016-07-17T23:46:56.370566 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/application_static-dfa728160c3cdebc633c2f6fb3823411530b307044f4dfe460790eef00b4e421.js.gz
|
55
|
-
I, [2016-07-17T23:46:56.372895 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/application_static-17ed778d5061d4797556632b7bfbf405e067d9e7f140060a7f56a09788251f16.css
|
56
|
-
I, [2016-07-17T23:46:56.373012 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/application_static-17ed778d5061d4797556632b7bfbf405e067d9e7f140060a7f56a09788251f16.css.gz
|
57
|
-
I, [2016-07-17T23:46:56.374531 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/2ac2dd94f9b7e54292f6d051f1e4e756-ab14eebb171a9a5c9bfdeb2f88933d2dc4904ea8bb09444984e52b13d230e251.svg
|
58
|
-
I, [2016-07-17T23:46:56.374818 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/2ac2dd94f9b7e54292f6d051f1e4e756-ab14eebb171a9a5c9bfdeb2f88933d2dc4904ea8bb09444984e52b13d230e251.svg.gz
|
59
|
-
I, [2016-07-17T23:46:56.392207 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/5cf5db49df178f9357603f945752a1ef-033650e1d6193b70d59bb60e773f47b6d9aefdd56abc7ccdba3c7bed4e57ccad.png
|
60
|
-
I, [2016-07-17T23:46:56.393208 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/8970f5e1e92aea933b502a2d73976b76-877bde3739dc7080c3fb00ee9012db6f21ed0dbbf11cd596dbb6e1a35bfb71f9.png
|
61
|
-
I, [2016-07-17T23:46:56.395490 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/ecb4572a5e478b107dfcb60c16a7eefa-6d1ab3741d5a164dc2aab48bb74429aebe2e2e29606feca581081697624dc18c.ttf
|
62
|
-
I, [2016-07-17T23:46:56.395846 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/ecb4572a5e478b107dfcb60c16a7eefa-6d1ab3741d5a164dc2aab48bb74429aebe2e2e29606feca581081697624dc18c.ttf.gz
|
63
|
-
I, [2016-07-17T23:46:56.396979 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fbd0d00cc9b670f05c17893a40da08d0-5731789fd0d7847a582b52b55a83e7a0ad4684acd5a9b487557635a08c112d0e.svg
|
64
|
-
I, [2016-07-17T23:46:56.397669 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fbd0d00cc9b670f05c17893a40da08d0-5731789fd0d7847a582b52b55a83e7a0ad4684acd5a9b487557635a08c112d0e.svg.gz
|
65
|
-
I, [2016-07-17T23:46:56.399261 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fc2dcaaf2057331ff76c5d37e1aa7056-efba50c701b697fc8160603b9e876adcf47511f35af68701db285272c965a45f.svg
|
66
|
-
I, [2016-07-17T23:46:56.399660 #77382] INFO -- : Writing /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fc2dcaaf2057331ff76c5d37e1aa7056-efba50c701b697fc8160603b9e876adcf47511f35af68701db285272c965a45f.svg.gz
|
67
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/2ac2dd94f9b7e54292f6d051f1e4e756-ab14eebb171a9a5c9bfdeb2f88933d2dc4904ea8bb09444984e52b13d230e251.svg to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/2ac2dd94f9b7e54292f6d051f1e4e756.svg
|
68
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/2ac2dd94f9b7e54292f6d051f1e4e756-ab14eebb171a9a5c9bfdeb2f88933d2dc4904ea8bb09444984e52b13d230e251.svg.gz to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/2ac2dd94f9b7e54292f6d051f1e4e756.svg.gz
|
69
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/5cf5db49df178f9357603f945752a1ef-033650e1d6193b70d59bb60e773f47b6d9aefdd56abc7ccdba3c7bed4e57ccad.png to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/5cf5db49df178f9357603f945752a1ef.png
|
70
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/8970f5e1e92aea933b502a2d73976b76-877bde3739dc7080c3fb00ee9012db6f21ed0dbbf11cd596dbb6e1a35bfb71f9.png to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/8970f5e1e92aea933b502a2d73976b76.png
|
71
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/ecb4572a5e478b107dfcb60c16a7eefa-6d1ab3741d5a164dc2aab48bb74429aebe2e2e29606feca581081697624dc18c.ttf to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/ecb4572a5e478b107dfcb60c16a7eefa.ttf
|
72
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/ecb4572a5e478b107dfcb60c16a7eefa-6d1ab3741d5a164dc2aab48bb74429aebe2e2e29606feca581081697624dc18c.ttf.gz to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/ecb4572a5e478b107dfcb60c16a7eefa.ttf.gz
|
73
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fbd0d00cc9b670f05c17893a40da08d0-5731789fd0d7847a582b52b55a83e7a0ad4684acd5a9b487557635a08c112d0e.svg to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fbd0d00cc9b670f05c17893a40da08d0.svg
|
74
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fbd0d00cc9b670f05c17893a40da08d0-5731789fd0d7847a582b52b55a83e7a0ad4684acd5a9b487557635a08c112d0e.svg.gz to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fbd0d00cc9b670f05c17893a40da08d0.svg.gz
|
75
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fc2dcaaf2057331ff76c5d37e1aa7056-efba50c701b697fc8160603b9e876adcf47511f35af68701db285272c965a45f.svg to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fc2dcaaf2057331ff76c5d37e1aa7056.svg
|
76
|
-
React On Rails: Symlinking /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fc2dcaaf2057331ff76c5d37e1aa7056-efba50c701b697fc8160603b9e876adcf47511f35af68701db285272c965a45f.svg.gz to /Users/justin/shakacode/react_on_rails/spec/dummy/public/assets/fc2dcaaf2057331ff76c5d37e1aa7056.svg
|
77
|
-
```
|
data/docs/outdated/rails3.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# Rails 3
|
2
|
-
|
3
|
-
* Please let us know if you find any issues with Rails 3.
|
4
|
-
* Rails 3 is confirmed to work up with versions up to 6.8.x.
|
5
|
-
* We are not testing it for new releases. If you find an issue, you will have to submit a PR to get it fixed.
|
6
|
-
|
7
|
-
## Known Issues
|
8
|
-
|
9
|
-
1. If you do not skip bootstrap for the generator, you cannot generate a working app, as bootstrap-sass does not support Rails 3, or at least the version we're using.
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Convert Rails 5 API only app to a Rails app
|
2
|
-
|
3
|
-
1. Go to the directory where you created your app
|
4
|
-
|
5
|
-
```bash
|
6
|
-
$ rails new your-current-app-name
|
7
|
-
```
|
8
|
-
|
9
|
-
Rails will start creating the app and will skip the files you have already created. If there is some conflict then it will stop and you need to resolve it manually. be careful at this step as it might replace you current code in conflicted files.
|
10
|
-
|
11
|
-
2. Resolve conflicts
|
12
|
-
|
13
|
-
```
|
14
|
-
1. Press "d" to see the difference
|
15
|
-
2. If it is only adding lines then press "y" to continue
|
16
|
-
3. If it is removeing some of your code then press "n" and add all additions manually
|
17
|
-
```
|
18
|
-
|
19
|
-
3. Run `bundle install` and follow [the instructions for installing into an existing Rails app](https://www.shakacode.com/react-on-rails/docs/guides/installation-into-an-existing-rails-app/)
|
@@ -1,32 +0,0 @@
|
|
1
|
-
## In your engine
|
2
|
-
|
3
|
-
+ At the top of `config/initializers/react_on_rails.rb`
|
4
|
-
```ruby
|
5
|
-
ActiveSupport.on_load(:action_view) do
|
6
|
-
include ReactOnRailsHelper
|
7
|
-
end
|
8
|
-
```
|
9
|
-
+ In your `<engine_name>.gemspec`:
|
10
|
-
```ruby
|
11
|
-
s.add_dependency 'react_on_rails', '~> 6'
|
12
|
-
```
|
13
|
-
+ In your `lib/<engine_name>.rb` (the entry point for your engine)
|
14
|
-
```ruby
|
15
|
-
require "react_on_rails"
|
16
|
-
```
|
17
|
-
## In the project including your engine
|
18
|
-
|
19
|
-
Place `gem 'react_on_rails', '~> 6'` before the gem pointing at your engine in your gemfile.
|
20
|
-
|
21
|
-
Requiring `react_on_rails` and including the helper will get rid of any issues where react on rails or react_component is undefined.
|
22
|
-
|
23
|
-
As far as solving the assets issue, `lib/tasks/assets.rake` in `react_on_rails` would somehow have to know that `react_on_rails` was included in an engine, and decide the path accordingly. This might be impossible, especially in the case of multiple engines using `react_on_rails` in a single application.
|
24
|
-
|
25
|
-
Another solution would be to detach this rake task from the `rails assets:precompile` task. This can be done by adding `REACT_ON_RAILS_PRECOMPILE=false` to your environment. If you do so, then react assets will have to be bundled separately from `rails assets:precompile`.
|
26
|
-
|
27
|
-
# Github Issues
|
28
|
-
|
29
|
-
* [Integration with an engine #342](https://github.com/shakacode/react_on_rails/issues/342)
|
30
|
-
* [Feature: target destination option for the install generator #459](https://github.com/shakacode/react_on_rails/issues/459)
|
31
|
-
* [Integration with Rails 5 Engines #562](https://github.com/shakacode/react_on_rails/issues/562)
|
32
|
-
* [Run inside a Rails engine? #257](https://github.com/shakacode/react_on_rails/issues/257)
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# Using ReactOnRails in JavaScript
|
2
|
-
You can easily render React components in your JavaScript with `render` method that returns a [reference to the component](https://facebook.github.io/react/docs/more-about-refs.html) (virtual DOM element).
|
3
|
-
|
4
|
-
```js
|
5
|
-
/**
|
6
|
-
* ReactOnRails.render("HelloWorldApp", {name: "Stranger"}, 'app');
|
7
|
-
*
|
8
|
-
* Does this:
|
9
|
-
* ReactDOM.render(React.createElement(HelloWorldApp, {name: "Stranger"}),
|
10
|
-
* document.getElementById('app'))
|
11
|
-
*
|
12
|
-
* @param name Name of your registered component
|
13
|
-
* @param props Props to pass to your component
|
14
|
-
* @param domNodeId
|
15
|
-
* @param hydrate [optional] Pass truthy to update server rendered html. Default is falsy
|
16
|
-
* @returns {virtualDomElement} Reference to your component's backing instance
|
17
|
-
*/
|
18
|
-
ReactOnRails.render(componentName, props, domNodeId)
|
19
|
-
```
|
20
|
-
|
21
|
-
## Why do we need this?
|
22
|
-
Imagine that we have some event with jQuery, it allows us to set component state manually.
|
23
|
-
|
24
|
-
```html
|
25
|
-
<input id="input" type="range" min="0" max="100" />
|
26
|
-
<div id="root"></div>
|
27
|
-
|
28
|
-
<script>
|
29
|
-
var input = $("#input");
|
30
|
-
var component = ReactOnRails.render("componentName", { value: input.val() }, "root");
|
31
|
-
|
32
|
-
input.on("change", function(e) {
|
33
|
-
component.setState({ value: input.val() });
|
34
|
-
});
|
35
|
-
</script>
|
36
|
-
```
|
data/docs/rails/turbolinks.md
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
# Turbolinks and Turbo
|
2
|
-
|
3
|
-
## Updated to support Turbo
|
4
|
-
* See [PR 1374](https://github.com/shakacode/react_on_rails/pull/1374).
|
5
|
-
* Ability to use with Turbo (@hotwired/turbo), as Turbolinks gets obsolete.
|
6
|
-
|
7
|
-
To configure turbo the following option can be set:
|
8
|
-
`ReactOnRails.setOptions({ turbo: true })`
|
9
|
-
|
10
|
-
Turbo is not auto-detected like older Turbolinks.
|
11
|
-
|
12
|
-
*Below docs maybe outdated*
|
13
|
-
|
14
|
-
* See [Turbolinks on Github](https://github.com/rails/turbolinks)
|
15
|
-
* React on Rails currently supports 2.5.x of Turbolinks and 5.0.0 of Turbolinks 5.
|
16
|
-
* You may include Turbolinks either via yarn (recommended) or via the gem.
|
17
|
-
|
18
|
-
## Why Turbolinks?
|
19
|
-
As you switch between Rails HTML controller requests, you will only load the HTML and you will
|
20
|
-
not reload JavaScript and stylesheets. This definitely can make an app perform better, even if
|
21
|
-
the JavaScript and stylesheets are cached by the browser, as they will still require parsing.
|
22
|
-
|
23
|
-
## Requirements for Using Turbolinks
|
24
|
-
1. You are **not using [react-router](https://github.com/ReactTraining/react-router)** or you are prepared to deal with some potential issues with where react-router and Turbolinks overlaps.
|
25
|
-
2. You are **using one JS and one CSS file** throughout your app. Otherwise, you will have to figure out how best to handle multiple JS and CSS files throughout the app given Turbolinks.
|
26
|
-
|
27
|
-
## Why Not Turbolinks
|
28
|
-
1. [react-router](https://github.com/ReactTraining/react-router) handles the back and forward buttons, as does TurboLinks. You *might* be able to make this work. *Please share your findings.*
|
29
|
-
1. You want to do code splitting to minimize the JavaScript loaded.
|
30
|
-
|
31
|
-
## More Information
|
32
|
-
* CSRF tokens need thorough checking with Turbolinks5. Turbolinks5 changes the head element by JavaScript (not only body) on page changes with the correct csrf meta tag, but if the JS code parsed this from head when several windows were opened, then our specs were not all passing. I didn't look details however, may be it is app code related, not library code. Anyway it may need additional check because there is CSRF helper in ReactOnRails and it need to work with Turbolinks5.
|
33
|
-
* Turbolinks5 send requests without the `Accept: */*` in the header, only exactly like `Accept: text/html` which makes Rails behave a bit specifically compared to normal and mime-parsing, which is skipped by when Rails see */*. For some more details on Rails and */* can read [Mime Type Resolution in Rails](http://blog.bigbinary.com/2010/11/23/mime-type-resolution-in-rails.html)
|
34
|
-
* If you're using multiple Webpack bundles, be sure to ensure that there are no name conflicts between JS objects or redux store paths.
|
35
|
-
|
36
|
-
### Install Checklist
|
37
|
-
1. Include turbolinks via yarn as shown in the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/blob/8a6c8aa2e3b7ae5b08b0a9744fb3a63a2fe0f002/client/webpack.client.base.config.js#L22) or include the gem "turbolinks".
|
38
|
-
1. Included the proper "track" tags when you include the javascript and stylesheet:
|
39
|
-
```erb
|
40
|
-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => 'reload' %>
|
41
|
-
<%= javascript_include_tag 'application', 'data-turbolinks-track' => 'reload' %>
|
42
|
-
```
|
43
|
-
NOTE: for Turbolinks 2.x, use 'data-turbolinks-track' => true
|
44
|
-
1. Add turbolinks to your `application.js` file:
|
45
|
-
```javascript
|
46
|
-
//= require turbolinks
|
47
|
-
```
|
48
|
-
|
49
|
-
## Turbolinks 5
|
50
|
-
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.
|
51
|
-
|
52
|
-
For more information on Turbolinks 5: [https://github.com/turbolinks/turbolinks](https://github.com/turbolinks/turbolinks)
|
53
|
-
|
54
|
-
## Turbolinks from NPM
|
55
|
-
|
56
|
-
See the [instructions on installing from NPM](https://github.com/turbolinks/turbolinks#installation-using-npm).
|
57
|
-
|
58
|
-
```js
|
59
|
-
import Turbolinks from "turbolinks";
|
60
|
-
Turbolinks.start();
|
61
|
-
```
|
62
|
-
|
63
|
-
### async script loading
|
64
|
-
Generally async script loading can be done like:
|
65
|
-
```erb
|
66
|
-
<%= javascript_include_tag 'application', async: Rails.env.production? %>
|
67
|
-
```
|
68
|
-
If you use ```document.addEventListener("turbolinks:load", function() {...});``` somewhere in your code, you will notice, that Turbolinks 5 does not fire ```turbolinks:load``` on initial page load. A quick workaround is to use ```defer``` instead of ```async```:
|
69
|
-
```erb
|
70
|
-
<%= javascript_include_tag 'application', defer: Rails.env.production? %>
|
71
|
-
```
|
72
|
-
More information on this issue can be found here: https://github.com/turbolinks/turbolinks/issues/28
|
73
|
-
|
74
|
-
When loading your scripts asynchronously you may experience, that your Components are not registered correctly. Call ```ReactOnRails.reactOnRailsPageLoaded()``` to re-initialize like so:
|
75
|
-
```
|
76
|
-
document.addEventListener("turbolinks:load", function() {
|
77
|
-
ReactOnRails.reactOnRailsPageLoaded();
|
78
|
-
});
|
79
|
-
```
|
80
|
-
|
81
|
-
## Troubleshooting
|
82
|
-
To turn on tracing of Turbolinks events, put this in your registration file, where you register your components.
|
83
|
-
|
84
|
-
```js
|
85
|
-
ReactOnRails.setOptions({
|
86
|
-
traceTurbolinks: true,
|
87
|
-
turbo: true,
|
88
|
-
});
|
89
|
-
```
|
90
|
-
|
91
|
-
Rather than setting the value to true, you could set it to TRACE_TURBOLINKS, and then you could place this in your `webpack.client.base.config.js`:
|
92
|
-
|
93
|
-
Define this const at the top of the file:
|
94
|
-
```js
|
95
|
-
const devBuild = process.env.NODE_ENV !== 'production';
|
96
|
-
```
|
97
|
-
|
98
|
-
Add this DefinePlugin option:
|
99
|
-
```js
|
100
|
-
plugins: [
|
101
|
-
new webpack.DefinePlugin({
|
102
|
-
TRACE_TURBOLINKS: devBuild,
|
103
|
-
}),
|
104
|
-
```
|
105
|
-
|
106
|
-
At Webpack compile time, the value of devBuild is inserted into your file.
|
107
|
-
|
108
|
-
Once you do that, you'll see messages prefixed with **TURBO:** like this in the browser console:
|
109
|
-
|
110
|
-
Turbolinks Classic:
|
111
|
-
```
|
112
|
-
TURBO: WITH TURBOLINKS: document page:before-unload and page:change handlers installed. (program)
|
113
|
-
TURBO: reactOnRailsPageLoaded
|
114
|
-
```
|
115
|
-
|
116
|
-
Turbolinks 5:
|
117
|
-
```
|
118
|
-
TURBO: WITH TURBOLINKS 5: document turbolinks:before-render and turbolinks:render handlers installed. (program)
|
119
|
-
TURBO: reactOnRailsPageLoaded
|
120
|
-
```
|
121
|
-
|
122
|
-
We've noticed that Turbolinks doesn't work if you use the ruby gem version of jQuery and jQuery ujs. Therefore we recommend using the node packages instead. See the [tutorial app](https://github.com/shakacode/react-webpack-rails-tutorial) for how to accomplish this.
|
123
|
-
|
124
|
-
![2016-02-02_10-38-07](https://cloud.githubusercontent.com/assets/1118459/12760060/6546e254-c999-11e5-828b-a8aaa473e5bd.png)
|
@@ -1,43 +0,0 @@
|
|
1
|
-
## React on Rails Pro
|
2
|
-
|
3
|
-
Support React on Rails development [by becoming a Github sponsor](https://github.com/sponsors/shakacode) and get these benefits:
|
4
|
-
|
5
|
-
1. 1-hour per month of support via Slack, PR reviews, and Zoom for React on Rails,
|
6
|
-
React-Rails, Shakapacker, rails/webpacker, ReScript (ReasonML), TypeScript, Rust, etc.
|
7
|
-
2. React on Rails Pro Software that extends React on Rails with Node server rendering,
|
8
|
-
fragment caching, code-splitting, and other performance enhancements for React on Rails.
|
9
|
-
|
10
|
-
See the [React on Rails Pro Support Plan](https://www.shakacode.com/react-on-rails-pro/).
|
11
|
-
|
12
|
-
ShakaCode can also help you with your custom software development needs. We specialize in
|
13
|
-
marketplace and e-commerce applications that utilize both Rails and React.
|
14
|
-
Because we own [HiChee.com](https://hichee.com), we can leverage that code for your app!
|
15
|
-
|
16
|
-
Please email Justin Gordon [justin@shakacode.com](mailto:justin@shakacode.com), the
|
17
|
-
maintainer of React on Rails, for more information.
|
18
|
-
|
19
|
-
### Pro: Fragment Caching
|
20
|
-
|
21
|
-
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:
|
22
|
-
|
23
|
-
1. The `cache_key` takes the same parameters as any Rails `cache` view helper.
|
24
|
-
1. The **props** are passed via a block so that evaluation of the props is not done unless the cache is broken. Suppose you put your props calculation into some method called `some_slow_method_that_returns_props`:
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
<%= cached_react_component("App", cache_key: [@user, @post], prerender: true) do
|
28
|
-
some_slow_method_that_returns_props
|
29
|
-
end %>
|
30
|
-
```
|
31
|
-
|
32
|
-
Such fragment caching saves CPU work for your web server and greatly reduces the request time. It completely skips the evaluation costs of:
|
33
|
-
|
34
|
-
1. Database calls to compute the props.
|
35
|
-
2. Serialization the props values hash into a JSON string for evaluating JavaScript to server render.
|
36
|
-
3. Costs associated with evaluating JavaScript from your Ruby code.
|
37
|
-
4. Creating the HTML string containing the props and the server-rendered JavaScript code.
|
38
|
-
|
39
|
-
Note, even without server rendering (without step 3 above), fragment caching is still effective.
|
40
|
-
|
41
|
-
### Pro: Integration with Node.js for Server Rendering
|
42
|
-
|
43
|
-
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).
|
data/docs/testimonials/hvmn.md
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# HVMN Testimonial, Written by Paul Benigeri, October 12, 2018
|
2
|
-
|
3
|
-
For some years, we used React on Rails for server-side rendering at [HVMN](https://hvmn.com). Our entire backend was already built in Rails, and we love React. As a content & e-commerce site, server-side rendering is critical, for UX performance and SEO crawler indexing.
|
4
|
-
|
5
|
-
During the 12 months leading up to our React on Rails Pro transition, our traffic grew 10x. Our team of 2 engineers was focused on shipping features, and we started to face performance issues. We had some fragment caching of our React server rending, but it didn’t work that well.
|
6
|
-
|
7
|
-
I discussed our growing pains with Justin, and as it turned out, ShakaCode just came out with React on Rails Pro and set it up on [egghead.io](https://egghead.io). The performance improvements were impressive, and Justin’s team was an ideal partner to help with the integration.
|
8
|
-
|
9
|
-
We decided to give it a shot. Over three weeks, the ShakaCode team helped us migrate to React on Rails Pro, set up Webpack v4, migrated our entire asset pipeline to Webpack v4.
|
10
|
-
|
11
|
-
Results were great. Our blog and product pages are 80-90% faster after that effort. The improved fragment caching was quick to set up and made a huge dent in our average server response times. We also observed an additional drop in response times when ShakaCode shipped the standalone Node server-side React renderer.
|
12
|
-
|
13
|
-
Working with ShakaCode was a pleasure. Justin is one of the smartest Rails architects I know, and his team was responsive and productive.
|
14
|
-
|
15
|
-
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.
|
16
|
-
|
17
|
-
If you have any questions, please reach out.
|
18
|
-
|
19
|
-
Paul Benigeri, Head of E-Commerce
|
20
|
-
|
21
|
-
[paul@hvmn.com](mailto:paul@hvmn.com), [LinkedIn](https://www.linkedin.com/in/benigeri/)
|
22
|
-
|
23
|
-
Related 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)
|
24
|
-
|
25
|
-
[![image](https://user-images.githubusercontent.com/1118459/46911126-577abd00-ceee-11e8-86c6-6703ff80fc2f.png)](https://www.linkedin.com/in/benigeri/)
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# ResortPass Testimonial, by Leora Juster, December 10, 2018
|
2
|
-
|
3
|
-
Many can write code that "works." Even fewer can write sophisticated code that both works and reflects a deep understanding of the technologies and paradigms involved. Only a select few can do the aforementioned while assisting in managing the expectations and time constraints of less technically informed members of software product teams to make the best design decisions possible. 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. The code and CSS files are well-organized and contain repeatable patterns easy to understand, allowing my team to build on what has already been accomplished. I learned a great deal from my interactions with Justin and his team, as they are just as great teachers as they are developers, and feel like I get to continually learn from them as I build on top of their code. Their different support and pro plan options make it easy to build a continuous professional relationship despite fluctuations in my team's funding, and their team is always extremely personable, punctual, and professional.
|
4
|
-
|
5
|
-
Leora Juster, Full-Stack Lead Software Developer
|
6
|
-
|
7
|
-
[LinkedIn](https://www.linkedin.com/in/leora-juster-38933050)
|
8
|
-
|
9
|
-
![image](https://user-images.githubusercontent.com/1118459/50050877-30399b00-00ab-11e9-9e52-2977de45ccae.png)
|
10
|
-
|
11
|
-
[ResortPass](https://resortpass.com/)
|
12
|
-
|
13
|
-
[![2018-12-15_20-48-35](https://user-images.githubusercontent.com/1118459/50050866-03858380-00ab-11e9-8588-461112f8045b.png)](https://resortpass.com/)
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Testimonials
|
2
|
-
# [HVMN Testimonial, Written by Paul Benigeri, October 12, 2018](https://www.shakacode.com/react-on-rails/docs/testimonials/hvmn/)
|
3
|
-
|
4
|
-
> 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.
|
5
|
-
|
6
|
-
Full writeup [here](https://www.shakacode.com/react-on-rails/docs/testimonials/hvmn/).
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
# [Leora from ResortPass](https://www.shakacode.com/react-on-rails/docs/testimonials/resortpass/), December 10, 2018
|
11
|
-
|
12
|
-
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.
|
13
|
-
|
14
|
-
Full writeup [here](https://www.shakacode.com/react-on-rails/docs/testimonials/resortpass/).
|
15
|
-
|
16
|
-
---
|
17
|
-
|
18
|
-
From Joel Hooks, Co-Founder, Chief Nerd at [egghead.io](https://egghead.io/), January 30, 2017:
|
19
|
-
|
20
|
-
![2017-01-30_11-33-59](https://cloud.githubusercontent.com/assets/1118459/22443635/b3549fb4-e6e3-11e6-8ea2-6f589dc93ed3.png)
|
21
|
-
|
22
|
-
---
|
23
|
-
|
24
|
-
From Kyle Maune of Cooper Aerial, May 4, 2018
|
25
|
-
|
26
|
-
![image](https://user-images.githubusercontent.com/1118459/40891236-9b0b406e-671d-11e8-80ee-c026dbd1d5a2.png)
|
27
|
-
|
28
|
-
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).
|
data/jest.config.js
DELETED