Class: Rsg::Generators::Webpacker::InstallGenerator
- Inherits:
-
Base
- Object
- Base
- Rsg::Generators::Webpacker::InstallGenerator
- Defined in:
- lib/rsg/generators/webpacker/install_generator.rb
Instance Method Summary collapse
- #add_webpacker ⇒ Object
- #banner ⇒ Object
- #configure_js ⇒ Object
- #configure_landing ⇒ Object
- #configure_sass ⇒ Object
- #install_webpacker ⇒ Object
- #sanity_check ⇒ Object
Instance Method Details
#add_webpacker ⇒ Object
10 11 12 |
# File 'lib/rsg/generators/webpacker/install_generator.rb', line 10 def add_webpacker append_gem("webpacker", version: "~> 5.0") end |
#banner ⇒ Object
6 7 8 |
# File 'lib/rsg/generators/webpacker/install_generator.rb', line 6 def say("Configuring webpacker") end |
#configure_js ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rsg/generators/webpacker/install_generator.rb', line 18 def configure_js copy_file "application.js", "app/javascript/packs/application.js", force: true inject_into_file "app/views/layouts/application.html.erb", " <%= javascript_pack_tag 'application' %>\n ", before: /<\/body>/ end |
#configure_landing ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/rsg/generators/webpacker/install_generator.rb', line 33 def configure_landing template "landing_controller.rb.erb", "app/controllers/landing_controller.rb" copy_file "landing_show.html.erb", "app/views/landing/show.html.erb" inject_into_file "config/routes.rb", <<-CODE, before: "end" root 'landing#show' CODE end |
#configure_sass ⇒ Object
26 27 28 29 30 31 |
# File 'lib/rsg/generators/webpacker/install_generator.rb', line 26 def configure_sass copy_file "application.sass", "app/javascript/stylesheets/application.sass" gsub_file "app/views/layouts/application.html.erb", "stylesheet_link_tag", "stylesheet_pack_tag" end |
#install_webpacker ⇒ Object
14 15 16 |
# File 'lib/rsg/generators/webpacker/install_generator.rb', line 14 def install_webpacker rake("webpacker:install") end |
#sanity_check ⇒ Object
2 3 4 |
# File 'lib/rsg/generators/webpacker/install_generator.rb', line 2 def sanity_check raise "Can't configure webpacker on API apps" if api_mode? end |