Module: WebpackStats
- Defined in:
- lib/webpack_stats.rb
Defined Under Namespace
Modules: Helper
Constant Summary collapse
- REGEXP =
/(.+?)(?:-([0-9a-f]{20,}))?\.(\w+)/
Class Attribute Summary collapse
-
.reload ⇒ Object
Returns the value of attribute reload.
-
.splitter ⇒ Object
Returns the value of attribute splitter.
-
.stats_path ⇒ Object
Returns the value of attribute stats_path.
Class Method Summary collapse
- .assets ⇒ Object
- .configure {|_self| ... } ⇒ Object
- .load_assets ⇒ Object
- .load_stats ⇒ Object
- .split_asset_name(stats, asset_name) ⇒ Object
- .stats ⇒ Object
Class Attribute Details
.reload ⇒ Object
Returns the value of attribute reload.
11 12 13 |
# File 'lib/webpack_stats.rb', line 11 def reload @reload end |
.splitter ⇒ Object
Returns the value of attribute splitter.
11 12 13 |
# File 'lib/webpack_stats.rb', line 11 def splitter @splitter end |
.stats_path ⇒ Object
Returns the value of attribute stats_path.
11 12 13 |
# File 'lib/webpack_stats.rb', line 11 def stats_path @stats_path end |
Class Method Details
.assets ⇒ Object
17 18 19 |
# File 'lib/webpack_stats.rb', line 17 def assets @reload ? load_assets : @assets ||= load_assets end |
.configure {|_self| ... } ⇒ Object
13 14 15 |
# File 'lib/webpack_stats.rb', line 13 def configure yield self end |
.load_assets ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/webpack_stats.rb', line 29 def load_assets ret = {} _stats = stats _stats['assets'].each do |asset| key, value = split_asset_name(_stats, asset['name']) ret[key] = value end ret end |
.load_stats ⇒ Object
25 26 27 |
# File 'lib/webpack_stats.rb', line 25 def load_stats JSON.parse File.read @stats_path end |
.split_asset_name(stats, asset_name) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/webpack_stats.rb', line 39 def split_asset_name stats, asset_name if @splitter.respond_to? :call @splitter.call stats['publicPath'], asset_name else full_name, name, hash, ext = REGEXP.match(asset_name).to_a ["#{name}.#{ext}", File.join(stats['publicPath'], full_name)] end end |
.stats ⇒ Object
21 22 23 |
# File 'lib/webpack_stats.rb', line 21 def stats @reload ? load_stats : @stats ||= load_stats end |