Class: ReactManifest::Reporter

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/react_manifest/reporter.rb

Overview

Reports per-bundle sizes by reading the Sprockets compiled manifest.

Run after ‘rails assets:precompile` to see:

Bundle                  Raw (KB)   Gzip (KB)
ux_shared.js              420         130
ux_notifications.js        95          31  ✓
ux_reports.js             610         190  ⚠

Instance Method Summary collapse

Methods included from Logging

#log_debug, #log_info, #log_warn

Constructor Details

#initialize(config = ReactManifest.configuration) ⇒ Reporter

Returns a new instance of Reporter.



15
16
17
# File 'lib/react_manifest/reporter.rb', line 15

def initialize(config = ReactManifest.configuration)
  @config = config
end

Instance Method Details

#reportObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/react_manifest/reporter.rb', line 19

def report
  manifest = load_sprockets_manifest
  bundles  = collect_bundles(manifest)

  if bundles.empty?
    log_info "No ux_*.js bundles found in compiled assets."
    log_info "  Run `rails assets:precompile` first."
    return
  end

  print_table(bundles)
end