Created
November 1, 2017 14:00
-
-
Save troelskn/36936026ce88d021e63ef3ccf56dc294 to your computer and use it in GitHub Desktop.
Use sprockets-es6 to handle jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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