From 9a90e46b78ad2c17c780d4de765395fe7a7f1f0d Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Fri, 16 Jan 2026 15:12:01 +1100 Subject: [PATCH 1/3] Move mail css back to be managed by wepack It wil allow us to remove dependency on `rails-sass`, and `sass` which are not maintained anymore. More or less revert this PR: https://github.com/openfoodfoundation/openfoodnetwork/pull/12743 --- app/assets/stylesheets/mail.scss | 1 - app/assets/stylesheets/mail/all.scss | 3 --- app/helpers/application_helper.rb | 15 +++++++++++++++ app/views/layouts/mailer.html.haml | 2 +- app/views/spree/admin/orders/invoice.html.haml | 2 +- app/views/spree/admin/orders/invoice2.html.haml | 2 +- app/views/spree/admin/orders/invoice4.html.haml | 4 ++-- app/webpacker/css/mail/all.scss | 3 +++ .../stylesheets => webpacker/css}/mail/email.scss | 0 .../css}/mail/payments_list.scss | 0 app/webpacker/packs/mail.scss | 1 + config/initializers/assets.rb | 1 - 12 files changed, 24 insertions(+), 10 deletions(-) delete mode 100644 app/assets/stylesheets/mail.scss delete mode 100644 app/assets/stylesheets/mail/all.scss create mode 100644 app/webpacker/css/mail/all.scss rename app/{assets/stylesheets => webpacker/css}/mail/email.scss (100%) rename app/{assets/stylesheets => webpacker/css}/mail/payments_list.scss (100%) create mode 100644 app/webpacker/packs/mail.scss diff --git a/app/assets/stylesheets/mail.scss b/app/assets/stylesheets/mail.scss deleted file mode 100644 index e35654c0d2..0000000000 --- a/app/assets/stylesheets/mail.scss +++ /dev/null @@ -1 +0,0 @@ -@import './mail/all.scss'; diff --git a/app/assets/stylesheets/mail/all.scss b/app/assets/stylesheets/mail/all.scss deleted file mode 100644 index fa8445d726..0000000000 --- a/app/assets/stylesheets/mail/all.scss +++ /dev/null @@ -1,3 +0,0 @@ -@import '../../../webpacker/css/admin/globals/palette.scss'; -@import 'email'; -@import 'payments_list'; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4da992b8ef..fc242cf18c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -76,4 +76,19 @@ module ApplicationHelper def cache_key_with_locale(key, locale) Array.wrap(key) + ["v2", locale.to_s, I18nDigests.for_locale(locale)] end + + def pdf_stylesheet_pack_tag(source) + # With shakapacker dev server running, the wicked_pdf_stylesheet_pack_tag will produce a + # relative path, because we don't have `config.action_controller.asset_host`. Relative path + # can't be resolved by `wkhtmltopdf`. So we pass the wepacker dev server host and port to + # the shakapacker helper, so it generates the correct url. + # For more info: https://stackoverflow.com/questions/58490299/how-to-include-css-stylesheet-into-wicked-pdf/60541688#60541688 + if running_in_development? + options = { media: "all", + host: "#{Shakapacker.dev_server.host}:#{Shakapacker.dev_server.port}" } + stylesheet_pack_tag(source, **options) + else + wicked_pdf_stylesheet_pack_tag(source) + end + end end diff --git a/app/views/layouts/mailer.html.haml b/app/views/layouts/mailer.html.haml index 2a74b48ad9..0a6981a08f 100644 --- a/app/views/layouts/mailer.html.haml +++ b/app/views/layouts/mailer.html.haml @@ -5,7 +5,7 @@ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ %title = Spree::Config[:site_name] - = stylesheet_link_tag 'mail', media: "screen" + = stylesheet_pack_tag "mail", media: "screen" %body{:bgcolor => "#FFFFFF" } - unless @hide_ofn_navigation %table.head-wrap diff --git a/app/views/spree/admin/orders/invoice.html.haml b/app/views/spree/admin/orders/invoice.html.haml index a72e7c1fff..d1dbc32264 100644 --- a/app/views/spree/admin/orders/invoice.html.haml +++ b/app/views/spree/admin/orders/invoice.html.haml @@ -1,4 +1,4 @@ -= wicked_pdf_stylesheet_link_tag "mail" += pdf_stylesheet_pack_tag "mail" %table{:width => "100%"} %tbody diff --git a/app/views/spree/admin/orders/invoice2.html.haml b/app/views/spree/admin/orders/invoice2.html.haml index 935e370d7a..c55a1f6637 100644 --- a/app/views/spree/admin/orders/invoice2.html.haml +++ b/app/views/spree/admin/orders/invoice2.html.haml @@ -1,4 +1,4 @@ -= wicked_pdf_stylesheet_link_tag "mail" += pdf_stylesheet_pack_tag "mail" %table{:width => "100%"} %tbody diff --git a/app/views/spree/admin/orders/invoice4.html.haml b/app/views/spree/admin/orders/invoice4.html.haml index 6a5c22ac8b..6e92e589d5 100644 --- a/app/views/spree/admin/orders/invoice4.html.haml +++ b/app/views/spree/admin/orders/invoice4.html.haml @@ -1,4 +1,4 @@ -= wicked_pdf_stylesheet_link_tag "mail" += pdf_stylesheet_pack_tag "mail" %table{:width => "100%"} %tbody @@ -102,4 +102,4 @@ = render partial: 'spree/admin/orders/_invoice/order_note' .text-center - = link_to_platform_terms \ No newline at end of file + = link_to_platform_terms diff --git a/app/webpacker/css/mail/all.scss b/app/webpacker/css/mail/all.scss new file mode 100644 index 0000000000..087d2d1310 --- /dev/null +++ b/app/webpacker/css/mail/all.scss @@ -0,0 +1,3 @@ +@import '../admin/globals/palette.scss'; +@import 'email'; +@import 'payments_list'; diff --git a/app/assets/stylesheets/mail/email.scss b/app/webpacker/css/mail/email.scss similarity index 100% rename from app/assets/stylesheets/mail/email.scss rename to app/webpacker/css/mail/email.scss diff --git a/app/assets/stylesheets/mail/payments_list.scss b/app/webpacker/css/mail/payments_list.scss similarity index 100% rename from app/assets/stylesheets/mail/payments_list.scss rename to app/webpacker/css/mail/payments_list.scss diff --git a/app/webpacker/packs/mail.scss b/app/webpacker/packs/mail.scss new file mode 100644 index 0000000000..d4f981e355 --- /dev/null +++ b/app/webpacker/packs/mail.scss @@ -0,0 +1 @@ +@import "../css/mail/all.scss"; diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 37ea1edf62..d6d7a932d6 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -19,6 +19,5 @@ Rails.application.config.assets.precompile += [ 'web/all.js', 'darkswarm/all.js', 'shared/*', - 'mail.scss', '*.jpg', '*.jpeg', '*.png', '*.gif' '*.svg', ] From 1b03528acaae97d545abac32bef4b4d3604f7f0d Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Fri, 16 Jan 2026 15:45:54 +1100 Subject: [PATCH 2/3] Switch to v349_with-relaxed-dependencies for select2 It allows us to remove dependency on `rails-sass` Sass files are handled by `shakapacker/wepack`, so we no use for `rails-sass` --- Gemfile | 5 ++--- Gemfile.lock | 42 +++++++++++++++++------------------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Gemfile b/Gemfile index 44c1d371f1..068c1868b1 100644 --- a/Gemfile +++ b/Gemfile @@ -126,9 +126,8 @@ gem 'angular_rails_csrf' gem 'jquery-rails', '4.4.0' gem 'jquery-ui-rails', '~> 4.2' -# TODO move away from sass-rails, master branch will get rid of dependency, so we can move to -# https://github.com/sass/embedded-host-node -gem "select2-rails", github: "openfoodfoundation/select2-rails", branch: "v349_with_thor_v1" +gem "select2-rails", github: "openfoodfoundation/select2-rails", + branch: "v349_with-relaxed-dependencies" gem 'good_migrations' diff --git a/Gemfile.lock b/Gemfile.lock index 500251293e..a089dcdc10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,11 +10,10 @@ GIT GIT remote: https://github.com/openfoodfoundation/select2-rails.git - revision: fc240e85fbdf1878ff3c39d972c0cd9a312f5ed4 - branch: v349_with_thor_v1 + revision: 9693e0cc5b04938da46692d3fa83aa8934791981 + branch: v349_with-relaxed-dependencies specs: select2-rails (3.4.9) - sass-rails thor (>= 0.14) GIT @@ -305,7 +304,7 @@ GEM eventmachine (>= 1.0.0.beta.1) email_validator (2.2.4) activemodel - erb (6.0.0) + erb (6.0.1) erubi (1.13.1) et-orbi (1.3.0) tzinfo @@ -330,7 +329,7 @@ GEM webrick (~> 1.7) websocket-driver (>= 0.6, < 0.8) ffaker (2.25.0) - ffi (1.17.2) + ffi (1.17.2-x86_64-linux-gnu) flipper (1.3.6) concurrent-ruby (< 2) flipper-active_record (1.3.6) @@ -515,8 +514,7 @@ GEM net-protocol newrelic_rpm (9.24.0) nio4r (2.7.5) - nokogiri (1.18.10) - mini_portile2 (~> 2.8.2) + nokogiri (1.18.10-x86_64-linux-gnu) racc (~> 1.4) nokogiri-html5-inference (0.3.0) nokogiri (~> 1.14) @@ -575,7 +573,7 @@ GEM hashery (~> 2.0) ruby-rc4 ttfunk - pg (1.6.2) + pg (1.6.2-x86_64-linux) pp (0.6.3) prettyprint prettyprint (0.2.0) @@ -584,7 +582,7 @@ GEM pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - psych (5.2.6) + psych (5.3.1) date stringio public_suffix (7.0.0) @@ -686,7 +684,7 @@ GEM logger (~> 1.5) ostruct (~> 0.6) readline (~> 0.0) - rdoc (6.16.0) + rdoc (7.0.1) erb psych (>= 4.0.0) tsort @@ -806,13 +804,6 @@ GEM sanitize (7.0.0) crass (~> 1.0.2) nokogiri (>= 1.16.8) - sass (3.4.25) - sass-rails (5.0.8) - railties (>= 5.2.0) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) sd_notify (0.1.1) securerandom (0.4.1) semantic_range (3.1.0) @@ -824,11 +815,12 @@ GEM semantic_range (>= 2.3.0) shoulda-matchers (7.0.1) activesupport (>= 7.1) - sidekiq (7.2.4) - concurrent-ruby (< 2) - connection_pool (>= 2.3.0) - rack (>= 2.2.4) - redis-client (>= 0.19.0) + sidekiq (7.3.10) + base64 + connection_pool (>= 2.3.0, < 3) + logger + rack (>= 2.2.4, < 3.3) + redis-client (>= 0.23.0, < 1) sidekiq-scheduler (5.0.3) rufus-scheduler (~> 3.2) sidekiq (>= 6, < 8) @@ -876,7 +868,7 @@ GEM railties (>= 5.2) redis (>= 4.0, < 6.0) stringex (2.8.6) - stringio (3.1.8) + stringio (3.2.0) stripe (15.5.0) swd (2.0.3) activesupport (>= 3) @@ -963,10 +955,10 @@ GEM xml-simple (1.1.8) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.7.3) + zeitwerk (2.7.4) PLATFORMS - ruby + x86_64-linux DEPENDENCIES actionpack-action_caching From 5e57325ce24f188a7a3c042432017ac854c417e2 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Tue, 27 Jan 2026 09:53:39 +1100 Subject: [PATCH 3/3] Use ruby platform for bundler --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a089dcdc10..ee7f2c211f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -329,7 +329,7 @@ GEM webrick (~> 1.7) websocket-driver (>= 0.6, < 0.8) ffaker (2.25.0) - ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.2) flipper (1.3.6) concurrent-ruby (< 2) flipper-active_record (1.3.6) @@ -514,7 +514,7 @@ GEM net-protocol newrelic_rpm (9.24.0) nio4r (2.7.5) - nokogiri (1.18.10-x86_64-linux-gnu) + nokogiri (1.18.10) racc (~> 1.4) nokogiri-html5-inference (0.3.0) nokogiri (~> 1.14) @@ -573,7 +573,7 @@ GEM hashery (~> 2.0) ruby-rc4 ttfunk - pg (1.6.2-x86_64-linux) + pg (1.6.2) pp (0.6.3) prettyprint prettyprint (0.2.0) @@ -958,7 +958,7 @@ GEM zeitwerk (2.7.4) PLATFORMS - x86_64-linux + ruby DEPENDENCIES actionpack-action_caching