Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ matrix:

allow_failures:
- rvm: jruby-9.0.1.0
- gemfile: gemfiles/rails_4.2_sprockets_4.gemfile
- gemfile: gemfiles/rails_5_sprockets_4.gemfile

before_install:
- mkdir travis-phantomjs
Expand Down
2 changes: 2 additions & 0 deletions lib/react/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class Railtie < ::Rails::Railtie
if Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new("4.x")
sprockets_env.register_mime_type("application/jsx", extensions: [".jsx", ".js.jsx", ".es.jsx", ".es6.jsx"])
sprockets_env.register_transformer("application/jsx", "application/javascript", React::JSX::Processor)
sprockets_env.register_mime_type("application/jsx+coffee", extensions: [".jsx.coffee", ".js.jsx.coffee"])
sprockets_env.register_transformer("application/jsx+coffee", "application/jsx", Sprockets::CoffeeScriptProcessor)
elsif Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new("3.0.0")
sprockets_env.register_engine(".jsx", React::JSX::Processor, mime_type: "application/javascript")
else
Expand Down
4 changes: 4 additions & 0 deletions test/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Sprockets 4 expects this file
//
//= link application.js
//= link application.css
10 changes: 9 additions & 1 deletion test/react_asset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ class ReactAssetTest < ActionDispatch::IntegrationTest

test "the development version with addons is loaded" do
asset = Rails.application.assets.find_asset('react')
assert asset.pathname.to_s.end_with?('development-with-addons/react.js')
path =
if asset.respond_to?(:pathname)
# Sprockets < 4
asset.pathname.to_s
else
# Sprockets 4+
asset.filename
end
assert path.end_with?('development-with-addons/react.js')
end

test "the production build is optimized for production" do
Expand Down