diff --git a/.travis.yml b/.travis.yml index 439cdea65..374003f19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/lib/react/rails/railtie.rb b/lib/react/rails/railtie.rb index 706452968..3f6548a39 100644 --- a/lib/react/rails/railtie.rb +++ b/lib/react/rails/railtie.rb @@ -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 diff --git a/test/dummy/app/assets/config/manifest.js b/test/dummy/app/assets/config/manifest.js new file mode 100644 index 000000000..4265e5b70 --- /dev/null +++ b/test/dummy/app/assets/config/manifest.js @@ -0,0 +1,4 @@ +// Sprockets 4 expects this file +// +//= link application.js +//= link application.css diff --git a/test/react_asset_test.rb b/test/react_asset_test.rb index 0d97b1734..907cca59d 100644 --- a/test/react_asset_test.rb +++ b/test/react_asset_test.rb @@ -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