
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
webpack-lighthouse-plugin
Advanced tools
This plugin allows you to run Lighthouse from a Webpack build.
npm install --save-dev webpack-lighthouse-plugin
In webpack.config.js
:
const WebpackLighthousePlugin = require('webpack-lighthouse-plugin');
module.exports = {
...
plugins: [
new WebpackLighthousePlugin({
url: 'http://localhost:9001'
})
],
...
}
Insert into your webpack.config.js:
const WebpackLighthousePlugin = require('webpack-lighthouse-plugin');
module.exports = {
entry: 'sample.js',
output: {
filename: 'test.js'
},
plugins: [
new WebpackLighthousePlugin({
url: 'https://airhorner.com'
})
],
};
url
- the URL to run Lighthouse audits againstperf
- only report Lighthouse performance audits (instead of the full Progressive Web App audits)disableDeviceEmulation
- disables device emulation (false
by default)disableCPUThrottling
- disables cpu throttling (true
by default)disableNetworkThrottling
- disables network throttling (false
by default)saveAssets
- save the trace contents & screenshots to disksaveArtifacts
- save all gathered artifacts to diskJust get the time to first meaningful paint, time-to-interactive and perceptual speed-index:
plugins: [
new WebpackLighthousePlugin({
url: 'https://airhorner.com',
perf: true
})
],
plugins: [
new WebpackLighthousePlugin({
url: 'https://airhorner.com',
disableCPUThrottling: false
})
],
plugins: [
new WebpackLighthousePlugin({
url: 'https://airhorner.com',
saveAssets: true
})
],
If you require even more data, you can also pass saveArtifacts: true
.
webpack-lighthouse-plugin
with real mobile devicesSimilar to the Lighthouse module, this plugin can also be used with real phones. It works over remote debugging using the Android command line tools.
Before running the plugin as part of your Webpack build, run the following commands:
$ adb kill-server
$ adb devices -l
$ adb forward tcp:9222 localabstract:chrome_devtools_remote
You can then run webpack
against your build and instead of firing up a Chrome instance on desktop, it'll do this with
your mobile device Chrome instead. You will want to disable a few flags to improve the accuracy of your metrics:
plugins: [
new WebpackLighthousePlugin({
url: 'https://localhost:9000', // Port you are locally serving on
disableDeviceEmulation: true,
disableCPUThrottling: true,
disableNetworkThrottling: true // Only if you're going to use real 3G
})
],
Note: Webpack Dev Server targets development builds rather than production. Although you can run Lighthouse against a dev build, it's best run against builds closer to prod.
If you're trying to use webpack-dev-server with
this plugin, first run it against your local build using the webpack-dev-server
CLI:
$ webpack-dev-server build/
http://localhost:8080/webpack-dev-server/
Then make sure to reference the webpack-dev-server
URL in your WebpackLighthousePlugin
config:
plugins: [
new WebpackLighthousePlugin({
url: 'http://localhost:8080/webpack-dev-server/'
})
],
If opening a pull request, create an issue describing a fix or feature. Have your pull request point to the issue by writing your commits with the issue number in the message.
Make sure you lint your code by running npm run lint
and you can build the library by running
npm run build
.
Released under an Apache-2.0 license.
FAQs
A Lighthouse plugin for Webpack
The npm package webpack-lighthouse-plugin receives a total of 30 weekly downloads. As such, webpack-lighthouse-plugin popularity was classified as not popular.
We found that webpack-lighthouse-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.