From a1d4056a3dd85ee20542a6399cef5fd742deb037 Mon Sep 17 00:00:00 2001 From: Matt Rasband <2184696+mattrasband@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:21:14 -0600 Subject: [PATCH] Fixes a couple minor issues with bootstrap: 1. The `bootstrap.min.js` doesn't include all the dependencies, and consequently does not work out of the box. Adding `@popperjs/core` isn't straightforward. 1. The asset path to the bootstrap/dist/js directory is added twice. While it does not seem to negatively impact things - it's cleaner to ensure it's done once. --- Gemfile.lock | 1 + lib/install/bootstrap/install.rb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bbda716..5e1ece0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -199,6 +199,7 @@ PLATFORMS arm64-darwin-20 arm64-darwin-21 arm64-darwin-22 + arm64-darwin-23 x86_64-darwin-20 x86_64-darwin-21 x86_64-linux diff --git a/lib/install/bootstrap/install.rb b/lib/install/bootstrap/install.rb index abf8e1d..f712775 100644 --- a/lib/install/bootstrap/install.rb +++ b/lib/install/bootstrap/install.rb @@ -23,15 +23,15 @@ if Rails.root.join("config/importmap.rb").exist? say "Pin Bootstrap" - append_to_file "config/importmap.rb", %(pin "bootstrap", to: "bootstrap.min.js"\n) + append_to_file "config/importmap.rb", %(pin "bootstrap", to: "bootstrap.bundle.min.js"\n) - inject_into_file "config/initializers/assets.rb", after: /.*Rails.application.config.assets.paths.*\n/ do + inject_into_file "config/initializers/assets.rb", after: /.*\/bootstrap-icons\/font.*\n/ do <<~RUBY Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap/dist/js") RUBY end - append_to_file "config/initializers/assets.rb", %(Rails.application.config.assets.precompile << "bootstrap.min.js") + append_to_file "config/initializers/assets.rb", %(Rails.application.config.assets.precompile << "bootstrap.bundle.min.js") end add_package_json_script("build:css:compile", "sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules")