项目作者: blencorp

项目描述 :
A React component used for rendering Lighthouse JSON reports Demo:
高级语言: JavaScript
项目地址: git://github.com/blencorp/react-lighthouse-viewer.git
创建时间: 2019-02-15T22:00:03Z
项目社区:https://github.com/blencorp/react-lighthouse-viewer

开源协议:

下载


react-lighthouse-viewer

If you have generated lighthouse report using lighthouse CLI, you can use this component to render the JSON report inside React.

Installation

  1. yarn add react-lighthouse-viewer

Usage

  1. import React from 'react';
  2. import { render } from 'react-dom';
  3. import ReportViewer from 'react-lighthouse-viewer';
  4. import jsonReport from './report.json';
  5. const App = () => (
  6. <ReportViewer json={jsonReport} ></ReportViewer>
  7. );
  8. render(<App ></App>, document.getElementById("root"));

To generate lighthouse reports, use CLI

Install lighthouse globally

  1. npm install -g lighthouse

Run CLI: lighthouse https://blencorp.com --output=json --output-path=./report.json

By default, Lighthouse writes the report to an HTML file. You can control the output format by passing flags.

CLI options

  1. $ lighthouse --help
  2. lighthouse <url>
  3. Logging:
  4. --verbose Displays verbose logging [boolean]
  5. --quiet Displays no progress, debug logs or errors [boolean]
  6. Configuration:
  7. --save-assets Save the trace & devtools log to disk [boolean]
  8. --list-all-audits Prints a list of all available audits and exits [boolean]
  9. --list-trace-categories Prints a list of all required trace categories and exits [boolean]
  10. --print-config Print the normalized config for the given config and options, then exit. [boolean]
  11. --additional-trace-categories Additional categories to capture with the trace (comma-delimited).
  12. --config-path The path to the config JSON.
  13. --chrome-flags Custom flags to pass to Chrome (space-delimited). For a full list of flags, see
  14. http://peter.sh/experiments/chromium-command-line-switches/.
  15. Environment variables:
  16. CHROME_PATH: Explicit path of intended Chrome binary. If set must point to an executable of a build of
  17. Chromium version 66.0 or later. By default, any detected Chrome Canary or Chrome (stable) will be launched.
  18. [default: ""]
  19. --port The port to use for the debugging protocol. Use 0 for a random port [default: 0]
  20. --preset Use a built-in configuration. [choices: "full", "perf", "mixed-content"]
  21. --hostname The hostname to use for the debugging protocol. [default: "localhost"]
  22. --max-wait-for-load The timeout (in milliseconds) to wait before the page is considered done loading and the run should continue.
  23. WARNING: Very high values can lead to large traces and instability [default: 45000]
  24. --emulated-form-factor Controls the emulated device form factor (mobile vs. desktop) if not disabled [choices: "mobile", "desktop", "none"] [default: "mobile"]
  25. --enable-error-reporting Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More:
  26. https://git.io/vFFTO
  27. --gather-mode, -G Collect artifacts from a connected browser and save to disk. If audit-mode is not also enabled, the run will quit
  28. early. [boolean]
  29. --audit-mode, -A Process saved artifacts from disk [boolean]
  30. Output:
  31. --output Reporter for the results, supports multiple values [choices: "csv", "json", "html"] [default: "html"]
  32. --output-path The file path to output the results. Use 'stdout' to write to stdout.
  33. If using JSON or CSV output, default is stdout.
  34. If using HTML output, default is a file in the working directory with a name based on the test URL and date.
  35. If using multiple outputs, --output-path is appended with the standard extension for each output type. "reports/my-run" -> "reports/my-run.report.html", "reports/my-run.report.json", etc.
  36. Example: --output-path=./lighthouse-results.html
  37. --view Open HTML report in your browser [boolean]
  38. Options:
  39. --help Show help [boolean]
  40. --version Show version number [boolean]
  41. --blocked-url-patterns Block any network requests to the specified URL patterns [array]
  42. --disable-storage-reset Disable clearing the browser cache and other storage APIs before a run [boolean]
  43. --disable-device-emulation Disable all device form factor emulation. Deprecated: use --emulated-form-factor=none instead [boolean]
  44. --throttling-method Controls throttling method [choices: "devtools", "provided", "simulate"]
  45. --throttling.rttMs Controls simulated network RTT (TCP layer)
  46. --throttling.throughputKbps Controls simulated network download throughput
  47. --throttling.requestLatencyMs Controls emulated network RTT (HTTP layer)
  48. --throttling.downloadThroughputKbps Controls emulated network download throughput
  49. --throttling.uploadThroughputKbps Controls emulated network upload throughput
  50. --throttling.cpuSlowdownMultiplier Controls simulated + emulated CPU throttling
  51. --extra-headers Set extra HTTP Headers to pass with request [string]
  52. Examples:
  53. lighthouse <url> --view Opens the HTML report in a browser after the run completes
  54. lighthouse <url> --config-path=./myconfig.js Runs Lighthouse with your own configuration: custom audits, report
  55. generation, etc.
  56. lighthouse <url> --output=json --output-path=./report.json --save-assets Save trace, devtoolslog, and named JSON report.
  57. lighthouse <url> --disable-device-emulation Disable device emulation and all throttling.
  58. --throttling-method=provided
  59. lighthouse <url> --chrome-flags="--window-size=412,660" Launch Chrome with a specific window size
  60. lighthouse <url> --quiet --chrome-flags="--headless" Launch Headless Chrome, turn off logging
  61. lighthouse <url> --extra-headers "{\"Cookie\":\"monster=blue\"}" Stringify\'d JSON HTTP Header key/value pairs to send in requests
  62. lighthouse <url> --extra-headers=./path/to/file.json Path to JSON file of HTTP Header key/value pairs to send in requests
  63. For more information on Lighthouse, see https://developers.google.com/web/tools/lighthouse/.

Cool Guide by Brad Stiff

A guide to building a React component with webpack 4, publishing to npm, and deploying the demo to GitHub Pages Read more :+1:


Hacked with ❤️ by BLEN Corp in Washington, DC.