Class: Shakapacker::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/shakapacker/instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path: Rails.root, config_path: Rails.root.join("config/shakapacker.yml")) ⇒ Instance

Returns a new instance of Instance.



8
9
10
11
# File 'lib/shakapacker/instance.rb', line 8

def initialize(root_path: Rails.root, config_path: Rails.root.join("config/shakapacker.yml"))
  @root_path = root_path
  @config_path = Pathname.new(ENV["SHAKAPACKER_CONFIG"] || config_path)
end

Instance Attribute Details

#config_pathObject (readonly)

Returns the value of attribute config_path.



6
7
8
# File 'lib/shakapacker/instance.rb', line 6

def config_path
  @config_path
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



6
7
8
# File 'lib/shakapacker/instance.rb', line 6

def root_path
  @root_path
end

Instance Method Details

#commandsObject



41
42
43
# File 'lib/shakapacker/instance.rb', line 41

def commands
  @commands ||= Shakapacker::Commands.new self
end

#compilerObject



29
30
31
# File 'lib/shakapacker/instance.rb', line 29

def compiler
  @compiler ||= Shakapacker::Compiler.new self
end

#configObject



17
18
19
20
21
22
23
# File 'lib/shakapacker/instance.rb', line 17

def config
  @config ||= Shakapacker::Configuration.new(
    root_path: root_path,
    config_path: config_path,
    env: env
  )
end

#dev_serverObject



33
34
35
# File 'lib/shakapacker/instance.rb', line 33

def dev_server
  @dev_server ||= Shakapacker::DevServer.new config
end

#envObject



13
14
15
# File 'lib/shakapacker/instance.rb', line 13

def env
  @env ||= Shakapacker::Env.inquire self
end

#inlining_css?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/shakapacker/instance.rb', line 45

def inlining_css?
  dev_server.inline_css? && dev_server.hmr? && dev_server.running?
end

#manifestObject



37
38
39
# File 'lib/shakapacker/instance.rb', line 37

def manifest
  @manifest ||= Shakapacker::Manifest.new self
end

#strategyObject



25
26
27
# File 'lib/shakapacker/instance.rb', line 25

def strategy
  @strategy ||= Shakapacker::CompilerStrategy.from_config
end