Class: Webpacker::Remote

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

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(root_path: nil, config_path: nil, **config_content) ⇒ Remote

rubocop:disable Lint/MissingSuper



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/webpacker/remote.rb', line 16

def initialize(root_path: nil, config_path: nil, **config_content)
  # deliberately not calling `super` just emulating what's done there
  # otherwise defaults in super initialize would call `Rails`
  # let's unbind the gem from rails
  @config_path = config_path
  @root_path = root_path

  # additions
  @config_content = config_content.symbolize_keys
  # fetch manifest eagerly to fail fast in initiazer unless cache_manifest: false
  manifest.manifest_data if @config_content.fetch(:cache_manifest, true)
end

Instance Method Details

#configObject



34
35
36
37
38
39
40
# File 'lib/webpacker/remote.rb', line 34

def config
  @config ||= Webpacker::Remote::Configuration.new(
    root_path: root_path,
    config_path: config_path,
    **config_content
  )
end

#envObject

right now this only supports builds done ahead of time



43
44
45
# File 'lib/webpacker/remote.rb', line 43

def env
  'production'
end

#manifestObject

rubocop:enable Lint/MissingSuper



30
31
32
# File 'lib/webpacker/remote.rb', line 30

def manifest
  @manifest ||= Webpacker::Remote::Manifest.new(self)
end