Skip to content

Commit

Permalink
Adding Webpacker as a dependency for Rails 6.0.z builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii committed Nov 4, 2019
1 parent 2d605f6 commit 1b48537
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ else
case ENV['RAILS_VERSION']
when '6.0.0' # This will only be necessary until release 6.0.1 is published
gem 'sass-rails', '~> 5'
gem 'webpacker' # This is necessary or the generator will break
when /^5\./
gem 'capybara', '~> 2.18.0'
gem 'sass-rails', '~> 5'
Expand All @@ -47,6 +48,7 @@ else
gem 'sass-rails', '>= 5.0'
else
gem 'sass-rails'
gem 'webpacker' # This is necessary or the generator will break
end
end
# END ENGINE_CART BLOCK
Expand Down
20 changes: 3 additions & 17 deletions spec/test_app_templates/lib/generators/test_app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,17 @@ def inject_css
end

def inject_javascript
binding.pry
if Rails.version =~ /^6\./
# copy_file 'template/foo', 'app/assets/javascripts.js'

=begin
insert_into_file 'app/javascript/packs/application.js', after: 'require("channels")' do
%(
//= require_tree .
)
end
=end
copy_file 'app/assets/javascripts/application.js', 'app/assets/javascripts/application.js'

# Does this means that Webpacker becomes a hard-dependency?
insert_into_file 'app/assets/config/manifest.js', after: '//= link_directory ../stylesheets .css' do
%(
//= link_directory ../javascripts .js
)
end

insert_into_file 'app/views/layouts/application.html.erb', after: "<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>"
insert_into_file 'app/views/layouts/application.html.erb', after: "<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>" do
%(
<%= javascript_include_tag 'application' %>
)
Expand Down Expand Up @@ -83,10 +75,4 @@ def create_test_route
copy_file '../support/app/views/file_handler/main.html.erb', 'app/views/file_handler/main.html.erb'
copy_file '../support/app/views/file_handler/index.html.erb', 'app/views/file_handler/index.html.erb'
end

def install_webpacker
if Rails.version =~ /^6\./
rake 'webpacker:install'
end
end
end

0 comments on commit 1b48537

Please sign in to comment.