Skip to content

Commit

Permalink
Merge pull request #343 from Asvarox/remove-puppeteer
Browse files Browse the repository at this point in the history
replace puppeteer with playwright to prerender pages
  • Loading branch information
Asvarox authored Oct 10, 2024
2 parents c2f52da + bd08429 commit 4473071
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 466 deletions.
3 changes: 2 additions & 1 deletion .github/templates/run-playwright/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ inputs.project }}
restore-keys: |
${{ runner.os }}-playwright-${{ inputs.project }}
- run: pnpm playwright install --with-deps ${{ inputs.project }}
- run: pnpm playwright install --with-deps chromium ${{ inputs.project }}
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
- run: pnpm playwright install-deps ${{ inputs.project }}
Expand All @@ -51,3 +51,4 @@ runs:
path: |
playwright-report
test-results
build
2 changes: 0 additions & 2 deletions .github/templates/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ runs:
cache: 'pnpm'
- run: pnpm install
shell: bash
- run: pnpm exec puppeteer browsers install chrome
shell: bash
7 changes: 3 additions & 4 deletions docs/prerendering-ssg.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ putting params of the URL the query string this is now mitigated.
## Solution
During build, all known paths (kept in `src/routePaths.ts`) are passed to
[vite-plugin-html-prerender](https://github.com/saeedafzal/vite-plugin-html-prerender), which then uses Puppeteer to render
the pages and save them in appropriate folder structure.

Although the plugin is niche and not very popular, it's simple enough to be easily ported to this project and make it
compatible with it if it gets abandoned.
the pages and save them in appropriate folder structure. The project is copied and modified so it
1. Handles custom `basePath` (needed for branch deployment)
2. Uses Playwright rather than Puppeteer for rendering (so there's no need to double-install the browsers)

## Alternative solutions considered
### Next.js
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.4",
"puppeteer": "^21.11.0",
"react-refresh": "^0.14.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-visualizer": "^5.12.0",
Expand Down
Loading

0 comments on commit 4473071

Please sign in to comment.