Class: WebpackerLite::Configuration

Inherits:
FileLoader show all
Defined in:
lib/webpacker_lite/configuration.rb

Instance Attribute Summary

Attributes inherited from FileLoader

#data

Class Method Summary collapse

Methods inherited from FileLoader

load

Class Method Details

.base_pathObject



17
18
19
# File 'lib/webpacker_lite/configuration.rb', line 17

def base_path
  "/#{configuration.fetch(:webpack_public_output_dir, "webpack")}"
end

.base_urlObject

Uses the hot_reloading_host if appropriate



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/webpacker_lite/configuration.rb', line 22

def base_url
  if WebpackerLite::Env.hot_loading?
    host = configuration[:hot_reloading_host]
    if host.blank?
      raise "WebpackerLite's /config/webpacker_lite.yml needs a configuration value for the "\
        "`hot_reloading_host` for environment #{Rails.env}."
    end
    if host.starts_with?("http")
      host
    else
      "http://#{host}"
    end
  else
    base_path
  end
end

.configurationObject



39
40
41
42
43
# File 'lib/webpacker_lite/configuration.rb', line 39

def configuration
  load if WebpackerLite::Env.development?
  raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Configuration.load must be called first") unless instance
  instance.data
end

.file_pathObject



45
46
47
# File 'lib/webpacker_lite/configuration.rb', line 45

def file_path
  Rails.root.join("config", "webpacker_lite.yml")
end

.manifest_pathObject



7
8
9
10
# File 'lib/webpacker_lite/configuration.rb', line 7

def manifest_path
  Rails.root.join(webpack_public_output_dir,
                  configuration.fetch(:manifest, "manifest.json"))
end

.webpack_public_output_dirObject



12
13
14
15
# File 'lib/webpacker_lite/configuration.rb', line 12

def webpack_public_output_dir
  Rails.root.join(
    File.join("public", configuration.fetch(:webpack_public_output_dir, "webpack")))
end