Skip to content

Commit

Permalink
lighthouse on prerendered routes
Browse files Browse the repository at this point in the history
  • Loading branch information
kushagharahi committed Aug 13, 2023
1 parent 51a5346 commit d2375f1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/.lighthouserc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
const paths = require('../../build/paths');

const baseUrl = 'http://127.0.0.1:8080'
// We want paths with the trailing slash so the paths are the prerendered static pages, not javascript pages.
const pathsWithTrailingSlash = paths.map((path) => {
if (path !== '/') {
return `${path}/`
} else {
return path
}
})

module.exports = {
ci: {
collect: {
numberOfRuns: 1,
url: paths.map((path) => baseUrl + path),
url: pathsWithTrailingSlash.map((path) => baseUrl + path),
startServerCommand: 'npx http-server dist -p 8080',
},
upload: {
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lighthousescores.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ JSON.parse(reportLinks, (url, reportLink) => {
comment += `\n \`${url}\` : ${reportLink}`
})

console.log(comment)

module.exports = comment
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ command | description
`npm run dev-build` | Compile to `dist` w/o prerendering
`npm run prd-build` | Compile to `dist` with prerendering
`npm run run-prd-build` | Compile to `dist` with prerendering and runs a python 3 webserver
`npm run lint` | Runs linting against all .vue/.js files not in build/* (run `npm run lint -- --fix` to autofix)
`npm run lint` | Runs linting against all .vue/.js files not in build/*
`npm run lint -- --fix` | Auto fix linting errors
`npm run lighthouse` | Runs Google Lighthouse on all the paths in /build/paths.js (you may need to set `CHROME_PATH`, e.g, `export CHROME_PATH=/usr/bin/google-chrome`)
### Docker

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev-build": "webpack --config ./build/webpack.dev.js",
"start": "webpack serve --config ./build/webpack.dev.js",
"run-prd-build": "npm run prd-build && python3 -m http.server --directory dist/",
"lighthouse": "npm run prd-build && lhci autorun --upload.target=temporary-public-storage --config=.github/workflows/.lighthouserc.js",
"lighthouse": "npm run prd-build && lhci autorun --config=.github/workflows/.lighthouserc.js && node .github/workflows/lighthousescores.js",
"lint": "eslint . -c build/.eslintrc.js --ext .js,.vue"
},
"repository": "git+https://github.com/kushagharahi/kushagharahi.github.io.git",
Expand Down

0 comments on commit d2375f1

Please sign in to comment.