File tree 16 files changed +57235
-14
lines changed
dummy/vendor/assets/javascripts
16 files changed +57235
-14
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "directory" : "vendor/assets/"
3
+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ Gemfile.lock
4
4
test /dummy /tmp
5
5
gemfiles /* .lock
6
6
* .swp
7
+ /lib /assets /react-source /
Original file line number Diff line number Diff line change 6
6
7
7
Bundler ::GemHelper . install_tasks
8
8
9
+ require 'pathname'
10
+ require 'react/source'
11
+
12
+ namespace :react do
13
+ task :copy_assets do
14
+ assets_path = Pathname . new ( __dir__ ) . join ( 'lib/assets/react-source/' )
15
+ copy_react_asset ( 'react.js' , assets_path . join ( 'development/react.js' ) )
16
+ copy_react_asset ( 'react.min.js' , assets_path . join ( 'production/react.js' ) )
17
+ copy_react_asset ( 'react-with-addons.js' , assets_path . join ( 'development-with-addons/react.js' ) )
18
+ copy_react_asset ( 'react-with-addons.min.js' , assets_path . join ( 'production-with-addons/react.js' ) )
19
+ end
20
+
21
+ def copy_react_asset ( source , destination )
22
+ vendor_path = Pathname . new ( __dir__ ) . join ( 'vendor/react' )
23
+ FileUtils . mkdir_p ( destination . dirname . to_s )
24
+ FileUtils . cp ( vendor_path . join ( source ) , destination . to_s )
25
+ end
26
+ end
27
+
28
+ Rake ::Task [ :build ] . enhance ( %w( react:copy_assets ) )
29
+
9
30
require 'appraisal'
10
31
require 'rake/testtask'
11
32
@@ -16,5 +37,6 @@ Rake::TestTask.new(:test) do |t|
16
37
t . verbose = ENV [ 'TEST_VERBOSE' ] == '1'
17
38
t . warning = true
18
39
end
40
+ Rake ::Task [ :test ] . enhance ( %w( react:copy_assets ) )
19
41
20
42
task default : :test
Original file line number Diff line number Diff line change @@ -28,19 +28,19 @@ class Railtie < ::Rails::Railtie
28
28
end
29
29
end
30
30
31
- initializer "react_rails.setup_vendor" , group : :all do |app |
31
+ config . after_initialize do |app |
32
32
# We want to include different files in dev/prod. The development builds
33
33
# contain console logging for invariants and logging to help catch
34
34
# common mistakes. These are all stripped out in the production build.
35
35
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
40
- end
36
+ root_path = Pathname . new ( '../../../../' ) . expand_path ( __FILE__ )
41
37
38
+ directory = app . config . react . variant == :production ? 'production' : 'development'
39
+ directory += '-with-addons' if app . config . react . addons
40
+
41
+ app . assets . append_path ( root_path . join ( 'lib/assets/react-source/' ) . join ( directory ) . to_s )
42
+ app . assets . append_path ( root_path . join ( 'vendor/react/' ) . to_s )
42
43
43
- config . after_initialize do |app |
44
44
# Server Rendering
45
45
# Concat component_filenames together for server rendering
46
46
app . config . react . components_js = lambda {
@@ -59,6 +59,7 @@ class Railtie < ::Rails::Railtie
59
59
60
60
# Reload the JS VMs in dev when files change
61
61
ActionDispatch ::Reloader . to_prepare ( &do_setup )
62
+
62
63
end
63
64
64
65
Original file line number Diff line number Diff line change @@ -23,13 +23,10 @@ Gem::Specification.new do |s|
23
23
s . add_development_dependency 'test-unit' , '~> 2.5'
24
24
s . add_development_dependency 'turbolinks' , '>= 2.0.0'
25
25
26
-
27
26
s . add_dependency 'coffee-script-source' , '~>1.8'
28
27
s . add_dependency 'connection_pool'
29
28
s . add_dependency 'execjs'
30
29
s . add_dependency 'rails' , '>= 3.1'
31
- # If you change this, make sure to update VERSIONS.md:
32
- s . add_dependency 'react-source' , '~> 0.13'
33
30
s . add_dependency 'tilt'
34
31
35
32
s . files = Dir [
Original file line number Diff line number Diff line change 4
4
class ReactTest < ActionDispatch ::IntegrationTest
5
5
6
6
test 'asset pipeline should deliver react file in a non-production variant' do
7
- actual_react_file_path = File . expand_path ( "../dummy/tmp/react-rails/react.js" , __FILE__ )
8
- actual_react_file_content = File . read actual_react_file_path
7
+ app_react_file_path = File . expand_path ( "../dummy/vendor/assets/javascripts/react.js" , __FILE__ )
9
8
10
9
react_file_token = "'test_confirmation_token_react_content_non_production';\n " ;
11
- File . open ( actual_react_file_path , 'w' ) { | f | f . write react_file_token }
10
+ File . write ( app_react_file_path , react_file_token )
12
11
13
12
get '/assets/react.js'
14
13
15
- File . open ( actual_react_file_path , 'w' ) { | f | f . write actual_react_file_content }
14
+ File . unlink ( app_react_file_path )
16
15
FileUtils . rm_r CACHE_PATH if CACHE_PATH . exist?
17
16
18
17
assert_response :success
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " react" ,
3
+ "version" : " 0.13.2" ,
4
+ "main" : " react.js" ,
5
+ "ignore" : [],
6
+ "homepage" : " https://github.com/facebook/react-bower" ,
7
+ "_release" : " 0.13.2" ,
8
+ "_resolution" : {
9
+ "type" : " version" ,
10
+ "tag" : " v0.13.2" ,
11
+ "commit" : " a400da781e82ecac87d69169e4592f1771dee96c"
12
+ },
13
+ "_source" : " git://github.com/facebook/react-bower.git" ,
14
+ "_target" : " ~0.13.2" ,
15
+ "_originalSource" : " react" ,
16
+ "_direct" : true
17
+ }
You can’t perform that action at this time.
0 commit comments