Class: Webpacker::Compiler
- Inherits:
-
Object
- Object
- Webpacker::Compiler
- Defined in:
- lib/webpacker/compiler.rb
Instance Method Summary collapse
- #compile ⇒ Object
-
#fresh? ⇒ Boolean
Returns true if all the compiled packs are up to date with the underlying asset files.
-
#initialize(webpacker) ⇒ Compiler
constructor
A new instance of Compiler.
-
#stale? ⇒ Boolean
Returns true if the compiled packs are out of date with the underlying asset files.
Constructor Details
#initialize(webpacker) ⇒ Compiler
Returns a new instance of Compiler.
17 18 19 |
# File 'lib/webpacker/compiler.rb', line 17 def initialize(webpacker) @webpacker = webpacker end |
Instance Method Details
#compile ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webpacker/compiler.rb', line 21 def compile if stale? run_webpack.tap do |success| # We used to only record the digest on success # However, the output file is still written on error, meaning that the digest should still be updated. # If it's not, you can end up in a situation where a recompile doesn't take place when it should. # See https://github.com/rails/webpacker/issues/2113 record_compilation_digest end else logger.info "Everything's up-to-date. Nothing to do" true end end |
#fresh? ⇒ Boolean
Returns true if all the compiled packs are up to date with the underlying asset files.
37 38 39 |
# File 'lib/webpacker/compiler.rb', line 37 def fresh? watched_files_digest == last_compilation_digest end |
#stale? ⇒ Boolean
Returns true if the compiled packs are out of date with the underlying asset files.
42 43 44 |
# File 'lib/webpacker/compiler.rb', line 42 def stale? !fresh? end |