Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use sprockets-es6 to handle jsx
# config/initializers/sprockets.rb
module Sprockets
if respond_to?(:register_transformer)
register_mime_type 'text/jsx', extensions: ['.jsx'], charset: :unicode
register_transformer 'text/jsx', 'application/javascript', ::BabelTransformer
register_preprocessor 'text/jsx', DirectiveProcessor
end
if respond_to?(:register_engine)
args = ['.jsx', ::BabelTransformer]
args << { mime_type: 'text/jsx', silence_deprecation: true } if Sprockets::VERSION.start_with?("3")
register_engine(*args)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.