Skip to content

Commit c8fc39a

Browse files
committedNov 27, 2014
Update README
1 parent 8e860f7 commit c8fc39a

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed
 

‎README.md

+30-21
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,55 @@ Full tutorial can be found at: [Fast Rich Client Rails Development With Webpack
1313
3. Enable the use of the JavaScript es6 transpiler.
1414
4. Enable easily using npm modules with a Rails application.
1515

16-
# Example of the following technologies:
16+
# Example of the following technologies
1717

18-
1. react
19-
2. react-bootstrap
20-
3. webpack with hot-reload
18+
1. React
19+
2. React-bootstrap
20+
3. Webpack with hot-reload
21+
4. Webpack ExtractTextPlugin
2122
4. es6-loader (es6 transpiler)
2223
5. Simultaneously working with Rails 4.2
2324
6. Deployable to Heroku
2425

25-
# Running without Rails using Hot Reload
26+
# Running without Rails using Module Hot Replacement
2627

2728
Setup node and run the node server.
29+
2830
```
2931
npm install
30-
cd webpack && node server.js
32+
cd webpack && webpack --config webpack.hot.config.js
33+
node server.js
3134
```
3235

3336
Point browser to [http://0.0.0.0:3000]().
3437

38+
Note: Make sure to invoke your local copy of the webpack executable as opposed
39+
to any globally installed webpack.
40+
See https://github.com/webpack/extract-text-webpack-plugin/blob/master/example/webpack.config.js
41+
3542
Save a change to a JSX file and see it update immediately in the browser! Note,
3643
any browser state still exists, such as what you've typed in the comments box.
3744
That's totally different than "Live Reload" which refreshes the browser.
3845

39-
# Rails
46+
# Running with Rails
4047

41-
## Automatically building the rails-bundle.js
42-
Run this command to automatically build the rails-bundle.js file in the
43-
javascript directory whenever your jsx files change.
48+
## Build Rails bundles
49+
Run this command to have webpack build the Rails bundles in the Rails
50+
asset pipeline.
51+
Note that the Webpack ExtractTextPlugin is used so that two bundles are generated:
52+
- rails-bundle.js which gets copied to app/assets/javascripts
53+
- bootstrap-and-customizations.css which gets copied in app/assets/stylesheet
54+
Observe how the bundles are automatically re-generated whever your JSX changes.
4455

4556
```
4657
cd webpack
4758
webpack -w --config webpack.rails.config.js
4859
```
4960

50-
## Run Rails
61+
## Run Rails server
5162

5263
```
64+
cd <rails_project_name>
5365
bundle install
5466
rake db:setup
5567
rails s -p 4000
@@ -58,17 +70,18 @@ Point browser to [http://0.0.0.0:4000]().
5870

5971
It's important to run the rails server on different port than the node server.
6072

61-
# Webpack Configuration
62-
`webpack.hot.config.js`: Used by server.js to run the demo server.
63-
`webpack.rails.config.js`: Used to generate the rails-bundle.js file
73+
# Webpack configuration files
74+
- `webpack.hot.config.js`: Used by server.js to run the demo express server.
75+
- `webpack.rails.config.js`: Used to generate the Rails bundles.
76+
- `webpack.common.config.js`: Common configuration file to minimize code duplication.
6477

65-
# Notes on Rails Assets
78+
# Notes on Rails assets
6679
## Javascript
67-
The `webpack.rails.config.js` file generates rails-bundle.js which is included
80+
The `webpack.rails.config.js` file generates rails-bundle.js which is then included
6881
by the Rails asset pipeline.
6982

7083
## Sass and images
71-
1. The Webpack server loads the images from the **symlink** of of the
84+
1. The Webpack server loads the images from the **symlink** of the
7285
app/assets/images directory.
7386
2. Since the images are not moved, Rails loads images via the normal asset
7487
pipeline features.
@@ -91,7 +104,3 @@ heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-mult
91104
```
92105

93106
This runs the two buildpacks in the `.buildpacks` directory.
94-
95-
# TO DO
96-
1. (Optionally) integrate twitter bootstrap assets into webpack build with way
97-
to configure same options for Rails and Webpack.

0 commit comments

Comments
 (0)