Class: Webpacker::Manifest
- Inherits:
-
FileLoader
- Object
- FileLoader
- Webpacker::Manifest
- Defined in:
- lib/webpacker/manifest.rb
Instance Attribute Summary
Attributes inherited from FileLoader
Class Method Summary collapse
-
.exist? ⇒ Boolean
Helper method to determine if the manifest file exists.
- .file_path ⇒ Object
-
.lookup(name) ⇒ Object
Throws an error if the file is not found.
-
.lookup_no_throw(name) ⇒ Object
Find the real file name from the manifest key.
-
.lookup_path(name) ⇒ Object
Why does this method exist? Testing? It’s not in the README.
Instance Method Summary collapse
Methods inherited from FileLoader
Class Method Details
.exist? ⇒ Boolean
Helper method to determine if the manifest file exists. Maybe Webpack needs to run? **Used by React on Rails.**
35 36 37 38 |
# File 'lib/webpacker/manifest.rb', line 35 def exist? path_object = Webpacker::Configuration.manifest_path path_object.exist? end |
.file_path ⇒ Object
12 13 14 |
# File 'lib/webpacker/manifest.rb', line 12 def file_path Webpacker::Configuration.manifest_path end |
.lookup(name) ⇒ Object
Throws an error if the file is not found. If Configuration.compile? then compilation is invoked the file is missing. React on Rails users will need to set Configuration.compile? to false as compilation is configured in the package.json for React on Rails.
20 21 22 23 24 25 26 |
# File 'lib/webpacker/manifest.rb', line 20 def lookup(name) if Webpacker::Configuration.compile? compile_and_find!(name) else find!(name) end end |
.lookup_no_throw(name) ⇒ Object
Find the real file name from the manifest key. Don’t throw an error if the file is simply missing from the manifest. Return nil in that case. If no manifest file exists, then throw an error. **Used by React on Rails.**
44 45 46 47 48 49 50 51 52 |
# File 'lib/webpacker/manifest.rb', line 44 def lookup_no_throw(name) instance.confirm_manifest_exists load_instance unless instance raise Webpacker::FileLoader::FileLoaderError.new("Webpacker::Manifest.load must be called first") end instance.data[name.to_s] end |
.lookup_path(name) ⇒ Object
Why does this method exist? Testing? It’s not in the README
29 30 31 |
# File 'lib/webpacker/manifest.rb', line 29 def lookup_path(name) Rails.root.join(File.join(Webpacker::Configuration.output_path, lookup(name))) end |
Instance Method Details
#confirm_manifest_exists ⇒ Object
91 92 93 |
# File 'lib/webpacker/manifest.rb', line 91 def confirm_manifest_exists raise missing_manifest_file_error(@path) unless File.exist?(@path) end |