Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Move to a static build and remote rendering #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

trotzig
Copy link
Contributor

@trotzig trotzig commented Jul 16, 2019

To make this plugin more robust and provide better screenshots, I'm switching approach a little. Instead of only using the precompiled (SSR) html files, I'm sending the whole static build over to happo workers and rendering things remotely.

trotzig added 9 commits July 16, 2019 22:35
This commit takes the happo-plugin-gatsby library closer to what
happo-plugin-storybook is doing:

1. invoke a static build
2. inject happo-specific javascript that remote workers understand
3. send the entire build to happo.io

This is better for a few different reasons:
- simpler - no longer a need for building yourself
- most likely faster as we're no longer relying on JSDOM to pre-render
pages
- more robust - results will be closer to what the user sees

This commit introduces a few breaking changes:
- no need for the pre-build
- `pageFilter` is replaced by `pages` - an array of urls to
visit/screenshoot
- `publicFolder` is now known as `outputDir` - which is more in line
with the storybook plugin.

A change was pushed to happo workers as part of testing this commit out.
By default, the `history` API in the browser is mocked. This is done to
prevent errors while running because a script navigated elsewhere. In
the gatsby case however, we rely on replaceState and pushState. So I had
to avoid mocking the history object for these types of runs.
Also remove the part about needing to pre-build now that building is
part of the tool itself.
Also, make sure that the register call doesn't fail when happo isn't
around.
This hasn't been required for quite some time.
The filter can be used to limit the number of pages compiled by gatsby.
This can keep the build size and time down significantly.
This will help people discover this module.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant