React.js builds
You can pick which React.js build (development, production, with or without add-ons) to serve in each environment by adding a config. Here are the defaults:
# config/environments/development.rb
MyApp::Application.configure do
config.react.variant = :development
end
# config/environments/production.rb
MyApp::Application.configure do
config.react.variant = :production
end
To include add-ons, use this config:
MyApp::Application.configure do
config.react.addons = true # defaults to false
end
After restarting your Rails server, //= require react will provide the build of React.js which was specified by the configurations.
react-rails offers a few other options for versions & builds of React.js. See VERSIONS.md for more info about using the react-source gem or dropping in your own copies of React.js.
JSX
After installing react-rails, restart your server. Now, .js.jsx files will be transformed in the asset pipeline.
BabelTransformer options
You can use babel's transformers and custom plugins, and pass options to the babel transpiler adding following configurations:
config.react.jsx_transform_options = {
blacklist: ['spec.functionName', 'validation.react', 'strict'], # default options
optional: ["transformerName"], # pass extra babel options
whitelist: ["useStrict"] # even more options[enter link description here][1]
}
Under the hood, react-rails uses ruby-babel-transpiler, for transformation.