Class: Webpacker::Compiler

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

Instance Method Summary collapse

Constructor Details

#initialize(webpacker) ⇒ Compiler

Returns a new instance of Compiler.



16
17
18
# File 'lib/webpacker/compiler.rb', line 16

def initialize(webpacker)
  @webpacker = webpacker
end

Instance Method Details

#compileObject



20
21
22
23
24
25
26
27
# File 'lib/webpacker/compiler.rb', line 20

def compile
  if stale?
    run_webpack
  else
    logger.debug "Everything's up-to-date. Nothing to do"
    true
  end
end

#fresh?Boolean

Returns true if manifest file mtime is newer than the timestamp of the last modified watched file

Returns:

  • (Boolean)


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

def fresh?
  manifest_mtime > latest_modified_timestamp
end

#stale?Boolean

Returns true if manifest file mtime is older than the timestamp of the last modified watched file

Returns:

  • (Boolean)


35
36
37
# File 'lib/webpacker/compiler.rb', line 35

def stale?
  !fresh?
end