From a951fd2c0658f7608db1e99fa41e068a2aac9789 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 9 Feb 2022 11:21:50 +0100 Subject: [PATCH] Create a new method pdf_stylesheet_pack_tag that actually include CSS file If running in developpement (ie. `Webpacker.dev_server.running?`), use webpacker to actually render/serve the CSS files. Source: https://stackoverflow.com/a/60541688 --- app/helpers/application_helper.rb | 9 +++++++++ app/views/spree/admin/orders/invoice.html.haml | 2 +- app/views/spree/admin/orders/invoice2.html.haml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e4e18601c7..8a507bfa98 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,4 +48,13 @@ module ApplicationHelper classes << "off-canvas" unless @hide_menu classes << @shopfront_layout end + + def pdf_stylesheet_pack_tag(source) + if running_in_development? + options = { media: "all", host: "#{Webpacker.dev_server.host}:#{Webpacker.dev_server.port}" } + stylesheet_pack_tag(source, **options) + else + wicked_pdf_stylesheet_pack_tag(source) + end + end end diff --git a/app/views/spree/admin/orders/invoice.html.haml b/app/views/spree/admin/orders/invoice.html.haml index 196a1a4777..55ad2104fb 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_pack_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 68ebcbfd68..2f1b152cdf 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_pack_tag "mail" += pdf_stylesheet_pack_tag "mail" %table{:width => "100%"} %tbody