@@ -29,34 +29,14 @@ class Railtie < ::Rails::Railtie
2929 end
3030
3131 initializer "react_rails.setup_vendor" , group : :all do |app |
32- # Mimic behavior of ember-rails...
33- # We want to include different files in dev/prod. The unminified builds
32+ # We want to include different files in dev/prod. The development builds
3433 # contain console logging for invariants and logging to help catch
35- # common mistakes. These are all stripped out in the minified build.
34+ # common mistakes. These are all stripped out in the production build.
3635
37- # Copy over the variant into a path that sprockets will pick up.
38- # We'll always copy to 'react.js' so that no includes need to change.
39- # We'll also always copy of JSXTransformer.js
40- tmp_path = app . root . join ( 'tmp/react-rails' )
41- filename = 'react' +
42- ( app . config . react . addons ? '-with-addons' : '' ) +
43- ( app . config . react . variant == :production ? '.min.js' : '.js' )
44- FileUtils . mkdir_p ( tmp_path )
45- FileUtils . cp ( ::React ::Source . bundled_path_for ( filename ) ,
46- tmp_path . join ( 'react.js' ) )
47- FileUtils . cp ( ::React ::Source . bundled_path_for ( 'JSXTransformer.js' ) ,
48- tmp_path . join ( 'JSXTransformer.js' ) )
49- app . assets . prepend_path tmp_path
50-
51- # Allow overriding react files that are not based on environment
52- # e.g. /vendor/assets/react/JSXTransformer.js
53- dropin_path = app . root . join ( "vendor/assets/react" )
54- app . assets . prepend_path dropin_path if dropin_path . exist?
55-
56- # Allow overriding react files that are based on environment
57- # e.g. /vendor/assets/react/development/react.js
58- dropin_path_env = app . root . join ( "vendor/assets/react/#{ app . config . react . variant } " )
59- app . assets . prepend_path dropin_path_env if dropin_path_env . exist?
36+ directory = ( app . config . react . variant || :production ) . to_s
37+ directory += 'with-addons' if app . config . react . addons
38+ app . assets . prepend_path ::React ::Source . bundled_path_for ( directory )
39+ app . assets . prepend_path ::React ::Source . bundled_path_for ( '' ) # JSXTransformer.js
6040 end
6141
6242
0 commit comments