Sha256: 2dc835556ac949aeb1743707a7ef392a942a06d88671715bedfd9906c8ebdf40
Contents?: true
Size: 1.39 KB
Versions: 17
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true module Bs5 class InstallGenerator < Rails::Generators::Base source_root File.expand_path('templates', __dir__) def add_bootstrap # rubocop:disable Metrics/MethodLength run 'yarn add bootstrap@next @popperjs/core' create_file 'app/javascript/packs/styles.scss', <<~HEREDOC @import "~bootstrap/scss/bootstrap"; HEREDOC copy_file 'bs5.js', 'app/javascript/bs5.js' append_file 'app/javascript/packs/application.js', <<~HEREDOC import * as bs5 from "bs5"; document.addEventListener("turbolinks:load", function () { bs5.start(); }); HEREDOC inject_into_file 'app/views/layouts/application.html.erb', before: '</head>' do <<~HEREDOC <%= stylesheet_pack_tag 'styles', media: 'all', 'data-turbolinks-track': 'reload' %> <meta name="viewport" content="width=device-width, initial-scale=1"> HEREDOC end inject_into_file 'app/controllers/application_controller.rb', after: "ActionController::Base\n" do <<~HEREDOC helper Bs5::Engine.helpers HEREDOC end inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do <<~HEREDOC mount Bs5::Engine => '/bs5' HEREDOC end gsub_file 'config/webpacker.yml', 'extract_css: false', 'extract_css: true' end end end
Version data entries
17 entries across 17 versions & 1 rubygems