From 1b48537ebd9efa0e920e16fd3458a045ba546b35 Mon Sep 17 00:00:00 2001 From: GriffinJ Date: Sun, 3 Nov 2019 21:18:04 -0500 Subject: [PATCH] Adding Webpacker as a dependency for Rails 6.0.z builds --- Gemfile | 2 ++ .../assets/javascripts}/application.js | 0 .../lib/generators/test_app_generator.rb | 20 +++---------------- 3 files changed, 5 insertions(+), 17 deletions(-) rename spec/test_app_templates/{lib/generators/templates => app/assets/javascripts}/application.js (100%) diff --git a/Gemfile b/Gemfile index 45d29515..88a97972 100644 --- a/Gemfile +++ b/Gemfile @@ -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' @@ -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 diff --git a/spec/test_app_templates/lib/generators/templates/application.js b/spec/test_app_templates/app/assets/javascripts/application.js similarity index 100% rename from spec/test_app_templates/lib/generators/templates/application.js rename to spec/test_app_templates/app/assets/javascripts/application.js diff --git a/spec/test_app_templates/lib/generators/test_app_generator.rb b/spec/test_app_templates/lib/generators/test_app_generator.rb index 8435800d..655a9d64 100644 --- a/spec/test_app_templates/lib/generators/test_app_generator.rb +++ b/spec/test_app_templates/lib/generators/test_app_generator.rb @@ -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' %> ) @@ -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