Skip to content

Commit 2d605f6

Browse files
committed
Inserting sprockets for Rails 6.0.z releases
1 parent 4f1c61a commit 2d605f6

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//= require_tree .
2+
//= require jquery
3+
//= require browse_everything

spec/test_app_templates/lib/generators/test_app_generator.rb

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,36 @@ def inject_css
2828
end
2929

3030
def inject_javascript
31-
insert_into_file 'app/assets/javascripts/application.js', after: '//= require_tree .' do
32-
%(
33-
//= require jquery
34-
//= require browse_everything
35-
)
31+
binding.pry
32+
if Rails.version =~ /^6\./
33+
# copy_file 'template/foo', 'app/assets/javascripts.js'
34+
35+
=begin
36+
insert_into_file 'app/javascript/packs/application.js', after: 'require("channels")' do
37+
%(
38+
//= require_tree .
39+
)
40+
end
41+
=end
42+
43+
insert_into_file 'app/assets/config/manifest.js', after: '//= link_directory ../stylesheets .css' do
44+
%(
45+
//= link_directory ../javascripts .js
46+
)
47+
end
48+
49+
insert_into_file 'app/views/layouts/application.html.erb', after: "<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>"
50+
%(
51+
<%= javascript_include_tag 'application' %>
52+
)
53+
end
54+
else
55+
insert_into_file 'app/assets/javascripts/application.js', after: '//= require_tree .' do
56+
%(
57+
//= require jquery
58+
//= require browse_everything
59+
)
60+
end
3661
end
3762
end
3863

@@ -58,4 +83,10 @@ def create_test_route
5883
copy_file '../support/app/views/file_handler/main.html.erb', 'app/views/file_handler/main.html.erb'
5984
copy_file '../support/app/views/file_handler/index.html.erb', 'app/views/file_handler/index.html.erb'
6085
end
86+
87+
def install_webpacker
88+
if Rails.version =~ /^6\./
89+
rake 'webpacker:install'
90+
end
91+
end
6192
end

0 commit comments

Comments
 (0)