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
This commit is contained in:
Jean-Baptiste Bellet
2022-02-09 11:21:50 +01:00
parent f065b4c787
commit a951fd2c06
3 changed files with 11 additions and 2 deletions

View File

@@ -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

View File

@@ -1,4 +1,4 @@
= wicked_pdf_stylesheet_pack_tag "mail"
= pdf_stylesheet_pack_tag "mail"
%table{:width => "100%"}
%tbody

View File

@@ -1,4 +1,4 @@
= wicked_pdf_stylesheet_pack_tag "mail"
= pdf_stylesheet_pack_tag "mail"
%table{:width => "100%"}
%tbody