Skip to content

Commit f299db0

Browse files
committed
Add addon config
This makes it possible to use the addons build of React. Closes #13
1 parent 7863d01 commit f299db0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ To transform your JSX into JS, simply create `.js.jsx` files, and ensure that th
5151

5252
## Configuring
5353

54+
### Variants
55+
5456
There are 2 variants available. `:development` gives you the unminified version of React. This provides extra debugging and error prevention. `:production` gives you the minified version of React which strips out comments and helpful warnings, and minifies.
5557

5658
```ruby
@@ -65,6 +67,16 @@ MyApp::Application.configure do
6567
end
6668
```
6769

70+
### Add-ons
71+
72+
Beginning with React v0.5, there is another type of build. This build ships with some "add-ons" that might be useful - [take a look at the React documentation for details](http://facebook.github.io/react/docs/addons.html). In order to make these available, we've added another configuration (which defaults to `false`).
73+
74+
```ruby
75+
MyApp::Application.configure do
76+
config.react.addons = true
77+
end
78+
```
79+
6880

6981
## CoffeeScript
7082

lib/react/rails/railstie.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ class Railtie < ::Rails::Railtie
1414
# common mistakes. These are all stripped out in the minified build.
1515
if variant = app.config.react.variant || ::Rails.env.test?
1616
variant ||= :development
17+
addons = app.config.react.addons || false
18+
1719
# Copy over the variant into a path that sprockets will pick up.
1820
# We'll always copy to 'react.js' so that no includes need to change.
1921
# We'll also always copy of JSXTransformer.js
2022
tmp_path = app.root.join('tmp/react-rails')
21-
filename = 'react' + (variant == :production ? '.min.js' : '.js')
23+
filename = 'react' + (addons ? '-with-addons' : '') + (variant == :production ? '.min.js' : '.js')
2224
FileUtils.mkdir_p(tmp_path)
2325
FileUtils.cp(::React::Source.bundled_path_for(filename),
2426
tmp_path.join('react.js'))

0 commit comments

Comments
 (0)