Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

perf(ci): cache Vite dependency optimization for Storybook builds (#71340)

mendral-app[bot]0121136147b4
diff --git a/.github/workflows/ci-storybook.yml b/.github/workflows/ci-storybook.yml
index 8986a01382de..5b291873c4ba 100644
--- a/.github/workflows/ci-storybook.yml
+++ b/.github/workflows/ci-storybook.yml
@@ -215,6 +215,17 @@ jobs:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ # Vite's dependency optimization cache (node_modules/.vite) is the most
+ # expensive part of the build — without it, Vite re-bundles 15k+ modules
+ # from scratch (~14 min on degraded runners vs <1 min with cache). The
+ # pnpm lockfile hash ensures the cache is invalidated when deps change.
+ - name: Restore Vite build cache
+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: common/storybook/node_modules/.vite
+ key: storybook-vite-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: storybook-vite-${{ runner.os }}-
+
- name: Build Storybook
env:
NODE_OPTIONS: --max-old-space-size=32768
@@ -222,6 +233,13 @@ jobs:
bin/turbo --filter=@posthog/storybook prepare
pnpm --filter=@posthog/storybook build --test
+ - name: Save Vite build cache
+ if: github.ref == 'refs/heads/master'
+ uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: common/storybook/node_modules/.vite
+ key: storybook-vite-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Upload Storybook build artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with: