I'm successfully using wicked_pdf with SASS in development. I'm including a single .scss
file, which contains several import
rules for other .sass
and .scss
files, via this helper:
def wicked_pdf_stylesheet_link_tag(*sources)
sources.collect { |source|
"<style type='text/css'>#{Rails.application.assets.find_asset("#{source}.css").body}</style>"
}.join("\n").gsub(/url\(['"](.+)['"]\)(.+)/,%[url("#{wicked_pdf_image_location("\\1")}")\\2]).html_safe
end
But switching to production the app still looks for the imported files which aren’t found.
I've added then a second manifest file to be pre–compiled in production.rb (config.assets.precompile += %w(pdf.css)
) which contains a single require
rule to pick up the mentioned .scss
file. This file is compiled just fine but it seems that the helper doesn't pick up the right file in production and still looks to load the imported .sass
files.
Has anyone experience how to solve this? The PDF creation requires absolute paths, which makes this task a bit more difficult.