You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`rails/webpacker` puts the necessary precompile steps automatically in the rake precompile step.
4
-
- See the [Heroku Deployment](https://www.shakacode.com/react-on-rails/docs/deployment/heroku-deployment/) doc for specifics regarding Heroku. The information for Heroku may apply to other deployments.
3
+
Shakapacker puts the necessary precompile steps automatically in the rake precompile step.
4
+
5
+
See the [Heroku Deployment](https://www.shakacode.com/react-on-rails/docs/deployment/heroku-deployment/) doc for specifics regarding Heroku. The information for Heroku may apply to other deployments.
Copy file name to clipboardExpand all lines: docs/guides/file-system-based-automated-bundle-generation.md
+7-6
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,7 @@ default: &default
64
64
```
65
65
66
66
the directory structure will look like this
67
+
67
68
```
68
69
app/javascript:
69
70
└── packs: # sets up webpack entries
@@ -100,15 +101,15 @@ Your layout would contain:
100
101
<%= stylesheet_pack_tag 'application' %>
101
102
```
102
103
103
-
104
104
Suppose, you want to use bundle splitting to minimize unnecessary javascript loaded on each page, you would put each of your components in the `packs` directory.
Copy file name to clipboardExpand all lines: docs/guides/how-react-on-rails-works.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# How React on Rails Works (with rails/webpacker)
1
+
# How React on Rails Works (with Shakapcker)
2
2
3
3
*Note, older versions of React on Rails pushed the Webpack bundles through the Asset Pipeline. This older method has *many* disadvantages, such as broken sourcemaps, performance issues, etc. If you need help migrating to the current way of bypassing the Asset Pipeline, [email Justin](mailto:[email protected]).*
4
4
5
-
Webpack is used to generate JavaScript and CSS "bundles" directly to your `/public` directory. [rails/webpacker](https://github.com/rails/webpacker) provides view helpers to access the Webpackgenerated (and fingerprinted) JS and CSS. These files totally skip the Rails asset pipeline. You are responsible for properly configuring your Webpack output. You will either use the standard Webpack configuration (*recommended*) or the `rails/webpacker` setup for Webpack.
5
+
Webpack is used to generate JavaScript and CSS "bundles" directly to your `/public` directory. [Shakapacker](https://github.com/shakacode/shakapacker) provides view helpers to access the Webpack-generated (and fingerprinted) JS and CSS. These files totally skip the Rails asset pipeline. You are responsible for properly configuring your Webpack output. You will either use the standard Webpack configuration (*recommended*) or the `shakapacker` setup for Webpack.
6
6
7
7
Ensure these generated bundle files are in your `.gitignore`, as you never want to add the large compiled bundles to git.
8
8
@@ -14,25 +14,25 @@ Optionally, you can also initialize a Redux store with the view or controller he
14
14
15
15
In most cases, you should use the `prerender: false` (default behavior) with the provided `react_component` helper method to render the React component from your Rails views. In some cases, such as when SEO is vital, or many users will not have JavaScript enabled, you can enable server-rendering by passing `prerender: true` to your helper, or you can simply change the default in `config/initializers/react_on_rails`.
16
16
17
-
Now the server will interpret your JavaScript. The default is to use [ExecJS](https://github.com/rails/execjs) and pass the resulting HTML to the client. If you want to maximize the perfomance of your server rendering, then you want to use React on Rails Pro which uses NodeJS to do the server rendering. See the [docs for React on Rails Pro](https://github.com/shakacode/react_on_rails/wiki).
17
+
Now the server will interpret your JavaScript. The default is to use [ExecJS](https://github.com/rails/execjs) and pass the resulting HTML to the client. If you want to maximize the performance of your server rendering, then you want to use React on Rails Pro which uses NodeJS to do the server rendering. See the [docs for React on Rails Pro](https://github.com/shakacode/react_on_rails/wiki).
18
18
19
19
## HTML Source Code
20
20
21
21
If you open the HTML source of any web page using React on Rails, you'll see the 3 parts of React on Rails rendering:
22
22
23
23
1. The wrapper div `<div id="HelloWorld-react-component-0">` specifies the div where to place the React rendering. It encloses the server-rendered HTML for the React component. If server rendering is not used (prerender: false), then the major difference is that the HTML rendered for the React component only contains the outer div: `<div id="HelloWorld-react-component-0"/>`. The first specification of the React component is just the same.
24
24
1. A script tag containing the properties of the React component, such as the registered name and any props. A JavaScript function runs after the page loads, using this data to build and initialize your React components.
25
-
1. Additional JavaScript is placed to console-log any messages, such as server rendering errors. Note: these serverside logs can be configured only to be sent to the server logs.
25
+
1. Additional JavaScript is placed to console-log any messages, such as server rendering errors. Note: these server-side logs can be configured only to be sent to the server logs.
26
26
27
27
You can see all this on the source for [reactrails.com](https://www.reactrails.com/)
28
28
29
29
## Building the Bundles
30
30
31
-
Each time you change your client code, you will need to re-generate the bundles (the webpack-created JavaScript files included in application.js). The included example Foreman `Procfile.dev` files will take care of this for you by starting a webpack process with the watch flag. This will watch your JavaScript code files for changes. Alternately, the `rails/webpacker` library also can ensure that your bundles are built.
31
+
Each time you change your client code, you will need to re-generate the bundles (the webpack-created JavaScript files included in application.js). The included example Foreman `Procfile.dev` files will take care of this for you by starting a webpack process with the watch flag. This will watch your JavaScript code files for changes. Alternatively, the `shakapacker` library also can ensure that your bundles are built.
32
32
33
33
For example, you might create a [Procfile.dev](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/Procfile.dev).
34
34
35
-
On production deployments that use asset precompilation, such as Heroku deployments, `rails/webpacker`, by default, will automatically run webpack to build your JavaScript bundles, running the command `bin/webpacker` in your app.
35
+
On production deployments that use asset precompilation, such as Heroku deployments, `shakapacker`, by default, will automatically run webpack to build your JavaScript bundles, running the command `bin/webpacker` in your app.
36
36
37
37
However, if you want to run a custom command to run webpack to build your bundles, then you will:
38
38
1. Define `config.build_production_command` in your [config/initializers/react_on_rails.rb](https://www.shakacode.com/react-on-rails/docs/guides/configuration/)
Copy file name to clipboardExpand all lines: docs/guides/how-to-conditionally-server-render-based-on-device-type.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ However, sometimes we want to have layouts sufficiently different that we can't
7
7
Here's an example:
8
8
9
9
## config/initializers/react_on_rails.rb
10
+
10
11
```ruby
11
12
moduleRenderingExtension
12
13
# Return a Hash that contains custom values from the view context that will get passed to
@@ -34,6 +35,6 @@ ReactOnRails.configure do |config|
34
35
end
35
36
```
36
37
37
-
Note, full details of the React on Rails confguration are [here in docs/basics/configuration.md](https://shakacode.com/react-on-rails/docs/guides/configuration/).
38
+
Note, full details of the React on Rails configuration are [here in docs/basics/configuration.md](https://shakacode.com/react-on-rails/docs/guides/configuration/).
38
39
39
40
See the doc file [docs/basics/generator-functions-and-railscontext.md](https://shakacode.com/react-on-rails/docs/guides/generator-functions-and-railscontext/#rails-context) for how your client-side code uses the device information
Copy file name to clipboardExpand all lines: docs/guides/installation-into-an-existing-rails-app.md
+9-7
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,18 @@
7
7
1. Add the following to your Gemfile and `bundle install`. We recommend fixing the version of React on Rails, as you will need to keep the exact version in sync with the version in your `package.json` file.
8
8
9
9
```ruby
10
-
gem "react_on_rails", "13.1.0"# Use the latest and the exact version
11
-
gem "shakapacker", "6.5.4"
10
+
gem "react_on_rails", "13.3.1"# Use the latest and the exact version
2. Run the following 2 commands to install Webpacker with React. Note, if you are using an older version of Rails than 5.1, you'll need to install webpacker with React per the instructions [here](https://github.com/rails/webpacker).
21
+
2. Run the following 2 commands to install Shakapakcer (Webpacker) with React. Note, if you are using an older version of Rails than 5.1, you'll need to install webpacker with React per the instructions [here](https://github.com/rails/webpacker).
22
22
23
23
```bash
24
24
rails webpacker:install
@@ -37,14 +37,16 @@
37
37
```bash
38
38
rails generate react_on_rails:install --help
39
39
```
40
-
5. Ensure that you have `overmind` or `foreman` installed
40
+
5. Ensure that you have `overmind` or `foreman` installed.
41
+
42
+
Note: `foreman` should be installed on the system not on your project. [Read more](https://github.com/ddollar/foreman/wiki/Don't-Bundle-Foreman)
41
43
42
44
6. Start your Rails server:
43
45
44
46
```bash
45
47
./bin/dev
46
48
```
47
-
Note: `foreman` defaults to PORT 5000 unless you set the value of PORT in your environment. For example, you can `export PORT=3000` to use the Rails default port of 3000. For the hello_world example this is already set.
49
+
Note: `foreman` defaults to PORT 5000 unless you set the value of PORT in your environment. For example, you can `export PORT=3000` to use the Rails default port of 3000. For the hello_world example, this is already set.
0 commit comments