You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
509 B

  1. # frozen_string_literal: true
  2. module PremailerWebpackStrategy
  3. def load(url)
  4. public_path_host = ENV['ASSET_HOST'] || ENV['LOCAL_DOMAIN']
  5. url = url.gsub(/\A\/\/#{public_path_host}/, '')
  6. if Webpacker.dev_server.running?
  7. url = File.join("#{Webpacker.dev_server.protocol}://#{Webpacker.dev_server.host_with_port}", url)
  8. HTTP.get(url).to_s
  9. else
  10. url = url[1..-1] if url.start_with?('/')
  11. File.read(Rails.root.join('public', url))
  12. end
  13. end
  14. module_function :load
  15. end