diff --git a/.github/workflows/.lighthouserc.js b/.github/workflows/.lighthouserc.js index a3a05b9..71dc3ce 100644 --- a/.github/workflows/.lighthouserc.js +++ b/.github/workflows/.lighthouserc.js @@ -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: { diff --git a/.github/workflows/lighthousescores.js b/.github/workflows/lighthousescores.js index 1f31534..74fcbbc 100644 --- a/.github/workflows/lighthousescores.js +++ b/.github/workflows/lighthousescores.js @@ -24,4 +24,6 @@ JSON.parse(reportLinks, (url, reportLink) => { comment += `\n \`${url}\` : ${reportLink}` }) +console.log(comment) + module.exports = comment \ No newline at end of file diff --git a/README.md b/README.md index 2297c54..b422d2b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index 82aa279..c5f8ee4 100644 --- a/package.json +++ b/package.json @@ -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",