I've been working on nudge-icons, a library of animated icons for React and Vue. It started with 50 icons and now has 500. With filled and half variants that's 546 components.
I use Storybook and Chromatic to catch visual regressions. Each icon has a story that shows its variants and states at five sizes, and Chromatic takes snapshots of them on every push to main and on every pull request.
That was fine with 50 icons. With 500, even a README fix meant 500 new snapshots. On Chromatic's free plan, with 5,000 snapshots a month, that's 10% of the allowance in one push.
So I started looking at TurboSnap. It only takes new snapshots of the stories a commit can affect and copies the rest from the last accepted build. Copies aren't free, but Chromatic bills them at a fifth of a snapshot.
Enabling it is one CLI flag, --only-changed. My setup needed a few more changes, because my icon components are generated and aren't tracked by git.
One story file per icon
TurboSnap works per story file. It takes the files changed in a commit, follows the module graph of the Storybook build, and retakes every story file that imports one of them, directly or through other modules.
All my icon stories used to be in one generated file that imported the whole package. Any change to any icon touched that file, so TurboSnap would have retaken all 500 stories every time.
Now the story generator writes one file per icon, and each file imports only that icon's components:
// apps/storybook/src/generated/icons/bell.stories.tsx // Generated by apps/storybook/scripts/gen-stories.ts. Do not edit. import type { Meta, StoryObj } from "@storybook/react-vite"; import { Bell } from "../../../../../packages/react/src/generated/icons/bell"; import { BellFilled } from "../../../../../packages/react/src/generated/icons/bell-filled"; import { IconMatrix } from "../../icon-matrix"; const meta = { title: "Icons/Bell", component: IconMatrix, args: { toggle: false, variants: [{ variant: "outline", Icon: Bell }, { variant: "filled", Icon: BellFilled }] }, } satisfies Meta<typeof IconMatrix>; export default meta; export const Matrix: StoryObj<typeof meta> = {}; The stories import each icon's own module, not the package index. The index re-exports every component, so importing it would put all icons back into every story's graph.
The problem with generated components
Each icon starts as two source files: icons/bell.svg with the drawing and icons/bell.json with the metadata and motion. A Node script reads them and writes the React and Vue components into packages/*/src/generated/. The generated files are in .gitignore, because CI rebuilds them anyway.
That breaks the way TurboSnap matches changes. Take a change to icons/bell.svg:
- The git diff contains
icons/bell.svg. - The Storybook module graph contains
generated/icons/bell.ts, but noticons/bell.svg. The SVG is read by a Node script withreadFileSync; nothing that Vite bundles imports it. - So the changed file matches no story, and TurboSnap would retake nothing.
The bell would look different, but Chromatic would copy the old snapshot and show no diff to review.
Importing the original SVG and JSON files
The fix is a few extra lines in each generated story file, importing the icon's own sources for their side effect:
// Sources, for TurboSnap only. import "../../../../../icons/bell.json"; import "../../../../../icons/bell.svg"; import "../../../../../icons/filled/bell.svg"; The story doesn't use them. Vite bundles the JSON and turns each SVG import into an asset URL, and that's enough to put both files in the graph. Now a change to icons/bell.svg reaches bell.stories.tsx and nothing else.
TypeScript also has to accept .svg imports. In the Storybook package that was one line in tsconfig.json: "types": ["node", "vite/client"].
Changes to the generator itself
Some files affect every icon but aren't imported by any story: the generator script and its helpers, which turn SVG into components and motion metadata into CSS. A change there should retake everything.
TurboSnap has --externals for this: if a changed file matches one of these patterns, every story is retaken. This is the Chromatic step in my CI:
- uses: actions/checkout@v7 with: # Chromatic compares against earlier builds by git history. fetch-depth: 0 # ...install... - run: pnpm build:storybook # runs `storybook build --stats-json` - run: > pnpm --filter @nudge-icons/storybook exec chromatic --storybook-build-dir storybook-static --only-changed --storybook-base-dir apps/storybook --externals 'scripts/build-icons.ts' --externals 'scripts/lib/**' The other settings TurboSnap needs here:
-
storybook build --stats-jsonwritespreview-stats.json, the module graph that TurboSnap reads. -
--storybook-base-dirpoints to the Storybook project inside the monorepo, so the paths in git and in the stats file match. -
fetch-depth: 0, because a shallow clone doesn't have the history Chromatic compares against.
Testing the dependency graph
Chromatic's CLI has a trace command that shows which stories a changed file would retake, without running a build. Paths are relative to the repository root:
$ npx chromatic trace -b apps/storybook -m compact icons/bell.svg ℹ Traced 1 changed file to 1 affected story file: — apps/storybook/src/generated/icons/bell.stories.tsx $ npx chromatic trace -b apps/storybook -m compact packages/react/src/lib/create-icon.tsx ℹ Traced 1 changed file to 501 affected story files One icon source reaches one story. The shared component factory reaches all 500 icon stories plus the playground story used by the animation tests. If an icon source ever traces to zero stories, the problem from above is back.
How many snapshots do I save?
These are three real builds. The billed column is my estimate, with a copy counted as 0.2 of a snapshot:

Build 30 in Chromatic: the 51 new icon stories were captured, the other 449 copied by TurboSnap.
| Change | Captured | Copied | Billed (approx.) | Without TurboSnap |
|---|---|---|---|---|
| Adding 50 icons | 50 | 99 | 70 | 149 |
| Redrawing paperclip | 1 | 148 | 31 | 149 |
| Adding 51 icons | 51 | 449 | 141 | 500 |
The paperclip fix is my favourite example: I changed one icon, and Chromatic took one new snapshot instead of 149.
A change to shared code still retakes everything, which is what I want: if create-icon.tsx changes, every icon can look different.
Copied snapshots are now most of the bill, and their share grows with the library. With 1,000 icons, changing one would still cost around 200 billed snapshots. I'll probably need to revisit this as the library grows.
Animation tests
Snapshots don't cover the motion, so I test the animations separately, with Playwright against the built Storybook. The tests hover icons, read the running animations with getAnimations(), and check that nothing is left attached when they finish. I wrote about that in How I test CSS animations with Playwright and getAnimations(). The live playground story those tests use is excluded from Chromatic with parameters: { chromatic: { disableSnapshot: true } }.
The code is on GitHub: the story generator and the CI workflow. The icons are at nudge-icons.github.io/nudge-icons.