Possible to avoid rebuilding within happo and have it point to an already built bundle?
We're running happo in our CI for our PR builds and that process goes:
- Build
- Test
- Screenshot Tests (Happo)
Part of step 3 is having happo rebuild our bundles, I'm curious if some one can point me in the direction of enabling happo to use the output from step 1. I saw that there is a tmpdir option (https://github.com/happo/happo.io#tmpdir) but haven't been successful with it yet. This is what my current .happo.js looks like (prior to my failed attemps with tmpdir):
module.exports = {
apiKey: process.env.HAPPO_API_KEY,
apiSecret: process.env.HAPPO_API_SECRET,
plugins: [
happoPluginStorybook({
configDir: 'docs/.storybook',
outputDir: '.happo-out',
}),
],
targets: {
chrome: new RemoteBrowserTarget('chrome', {
viewport: '1280x1024',
}),
},
type: 'react',
};
Hi @JonahMoses 👋
The tmpdir option isn't used (IIRC) when using the storybook plugin. This isn't supported right now, but it wouldn't take much to add an option to the happo-plugin-storybook code to allow reusing the build. Right around here is where the static package is created. We could add a useExistingBuild option to the plugin and skip the whole build phase if it's true.
The only tricky part here is that happo will occasionally run twice -- once for the base commit (the commit that the PR is based on) and once for the tip of the PR. The build in step 1 can't be used for the base commit, so we'll have to figure out how to only conditionally apply the useExistingBuild flag. It might involve setting an environment variable or something right around here to signal that we're generating the "previous" report.
@trotzig this would be incredible, as it would certainly cut down on some build time for us! Thank you for pointing this out.