No commit activity in last 3 years
No release in over 3 years
Preprocessor for Coffeescript with React JSX (CJSX). This gem makes it easy to integrate this into the Rails asset pipeline or other Sprockets chains. If you want to use CJSX without Sprockets, see the coffee-jsx gem, or the coffee-jsx npm module. This is an update version of sprockets-coffee-jsx gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

sprockets-coffee-jsx

Preprocessor for Coffeescript with React JSX (CJSX) support.

This is an updated version of sprockets-coffee-jsx gem.

This gem makes it easy to integrate this into the Rails asset pipeline or other Sprockets chains.

Usage

Add this gem to your Gemfile:

gem 'sprockets-coffee-jsx'

You can name your JSX asset files as .js.coffee.cjsx, .js.cjsx or .js.coffee.

Rack

If you're not using rails, you'll need to register the Sprockets preprocessor manually. Here is an adapted version of the Rack example provided by Sprockets, which additionally requires and registers the sprockets-coffee-jsx engine:

require 'sprockets'
require 'sprockets/coffee-jsx'
map '/assets' do
  environment = Sprockets::Environment.new
  environment.append_path 'app/assets/javascripts'
  environment.append_path 'app/assets/stylesheets'
  environment.register_mime_type 'text/cjsx', extensions: ['.cjsx', '.js.cjsx', '.js.coffee.cjsx'], charset: :unicode
  environment.register_transformer 'text/cjsx', 'application/javascript', Sprockets::CoffeeJsxScript
  environment.register_preprocessor 'application/javascript', Sprockets::CoffeeJsx
  environment.register_postprocessor 'application/javascript', Sprockets::CoffeeJsxPostprocessor
  run environment
end

map '/' do
  run YourRackApp
end

Middleman

Add the following to your config.rb file:

require 'sprockets/coffee-jsx'
::Sprockets.register_mime_type 'text/cjsx', extensions: ['.cjsx', '.js.cjsx', '.js.coffee.cjsx'], charset: :unicode
::Sprockets.register_transformer 'text/cjsx', 'application/javascript', Sprockets::CoffeeJsxScript
::Sprockets.register_preprocessor 'application/javascript', Sprockets::CoffeeJsx
::Sprockets.register_postprocessor 'application/javascript', Sprockets::CoffeeJsxPostprocessor

License

Released under the MIT License. See the LICENSE file for further details.