Class: Webpacker::Instance

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Instance.



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

def initialize(root_path: Rails.root, config_path: Rails.root.join("config/webpacker.yml"))
  @root_path, @config_path = root_path, config_path
end

Instance Attribute Details

#config_pathObject (readonly)

Returns the value of attribute config_path.



4
5
6
# File 'lib/webpacker/instance.rb', line 4

def config_path
  @config_path
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



4
5
6
# File 'lib/webpacker/instance.rb', line 4

def root_path
  @root_path
end

Instance Method Details

#commandsObject



34
35
36
# File 'lib/webpacker/instance.rb', line 34

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

#compilerObject



22
23
24
# File 'lib/webpacker/instance.rb', line 22

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

#configObject



14
15
16
17
18
19
20
# File 'lib/webpacker/instance.rb', line 14

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

#dev_serverObject



26
27
28
# File 'lib/webpacker/instance.rb', line 26

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

#envObject



10
11
12
# File 'lib/webpacker/instance.rb', line 10

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

#inlining_css?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/webpacker/instance.rb', line 38

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

#manifestObject



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

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