This repository was archived by the owner on Mar 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ def _requirejs_data(name, &block)
11
11
{ } . tap do |data |
12
12
if name
13
13
name += ".js" unless name =~ /\. js$/
14
- data [ 'main' ] = _javascript_path ( name ) . sub ( /\. js$/ , '' )
14
+ data [ 'main' ] = _javascript_path ( name ) .
15
+ sub ( /\. js$/ , '' ) .
16
+ sub ( baseUrl ( name ) , '' ) .
17
+ sub ( /\A \/ / , '' )
15
18
end
16
19
17
20
data . merge! ( yield controller ) if block_given?
@@ -54,6 +57,8 @@ def requirejs_include_tag(name=nil, &block)
54
57
# and in the build_config.
55
58
run_config [ 'paths' ] = paths
56
59
end
60
+
61
+ run_config [ 'baseUrl' ] = baseUrl ( name )
57
62
html . concat <<-HTML
58
63
< script > var require = #{ run_config . to_json } ;</ script>
59
64
HTML
@@ -89,4 +94,11 @@ def _javascript_path(name)
89
94
"/assets/#{ name } "
90
95
end
91
96
end
97
+
98
+ def baseUrl ( js_asset )
99
+ js_asset_path = javascript_path ( js_asset )
100
+ uri = URI . parse ( js_asset_path )
101
+ asset_host = uri . host && js_asset_path . sub ( uri . request_uri , '' )
102
+ [ asset_host , Rails . application . config . assets . prefix ] . join
103
+ end
92
104
end
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ class Engine < ::Rails::Engine
21
21
22
22
config . assets . precompile += config . requirejs . precompile
23
23
24
- manifest_path = File . join ( ::Rails . public_path , config . assets . prefix , "rjs_manifest.yml" )
24
+ manifest_directory = config . assets . manifest || File . join ( ::Rails . public_path , config . assets . prefix )
25
+ manifest_path = File . join ( manifest_directory , "rjs_manifest.yml" )
25
26
config . requirejs . manifest_path = Pathname . new ( manifest_path )
26
27
end
27
28
You can’t perform that action at this time.
0 commit comments