Skip to content

Instantly share code, notes, and snippets.

@schnittchen
Last active August 29, 2015 14:17
Show Gist options
  • Save schnittchen/935047fc8caa4bd26703 to your computer and use it in GitHub Desktop.
Save schnittchen/935047fc8caa4bd26703 to your computer and use it in GitHub Desktop.
# jsxlint does not consider files not ending in .jsx as containing JSX syntax.
# With react-rails, a .jsx file is not subject to 6to5/babel transformation,
# hence I cannot use JSX syntax and ES6 at the same time.
# This little hack (and a little convention) does the trick for me:
#
# The sprockets-es6 gem provides both transformations I want for the .es6 ending.
# I name my files ending in .es6.jsx (which happens to be descriptive as well)
# and make the .jsx transformation step a NOP (by overwriting the engine
# which has been registered for .jsx before by react-rails).
Rails.application.initializer "override_react_rails", after: "react_rails.setup_engine" do
# we need to make sure to run this after react-rails' initializer,
# hence this lives at the bottom of application.rb
# Kittens die here.
Rails.application.assets.register_engine '.jsx', Tilt::PlainTemplate
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment