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
12
13
# 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

  # For backward compatibility
  @config_path = Shakapacker.get_config_file_path_with_backward_compatibility(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



43
44
45
# File 'lib/shakapacker/instance.rb', line 43

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

#compilerObject



31
32
33
# File 'lib/shakapacker/instance.rb', line 31

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

#configObject



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

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

#dev_serverObject



35
36
37
# File 'lib/shakapacker/instance.rb', line 35

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

#envObject



15
16
17
# File 'lib/shakapacker/instance.rb', line 15

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

#inlining_css?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/shakapacker/instance.rb', line 47

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

#manifestObject



39
40
41
# File 'lib/shakapacker/instance.rb', line 39

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

#strategyObject



27
28
29
# File 'lib/shakapacker/instance.rb', line 27

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