Class: Webpacker::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/webpacker/source.rb

Overview

Translates a logical reference for a pack source into the final path needed in the HTML. This translation takes into account whether digesting is configured to happen, which it is by default in the production environment (as set via ‘Rails.configuration.x.webpacker[:digesting] = true`).

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Source

Returns a new instance of Source.



6
7
8
# File 'lib/webpacker/source.rb', line 6

def initialize(name)
  @name = name
end

Instance Method Details

#pathObject



10
11
12
13
14
15
16
17
18
# File 'lib/webpacker/source.rb', line 10

def path
  if config[:dev_server_host].present?
    "#{config[:dev_server_host]}/#{filename}"
  elsif config[:digesting]
    "/packs/#{digested_filename}"
  else
    "/packs/#{filename}"
  end
end